text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; set<int> ms; for (int i = 0; i < n; ++i) { int x; cin >> x; if (x) ms.insert(x); } cout << ms.size() << n ; return 0; }
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/* * Copyright (c) 2000 Stephen Williams () * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU * General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * ...
// Copyright 1986-1999, 2001-2013 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2013.4 (lin64) Build 353583 Mon Dec 9 17:26:26 MST 2013 // Date : Sat Mar 15 17:45:54 2014 // Host : macbook running 64-bit Arc...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 03/12/2016 06:26:54 PM // Design Name: // Module Name: shift_mux_array // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revis...
//`timescale 1 ms /1 us `include "mux81b.v" module chap4p32b_tb (S); // module declaration output [0:3] S; reg [0:3] S; //S[0]=A, S[1]=B, S[2]=C, S[3]=D wire [0:7] I; wire Y; integer fp; // program body assign I[0]=~S[3]; assign I[1]=~S[3]; assign I[2]=S[3]; assign I[3]=S[3]; assign I[4]=...
/* Shift Module Accepts the 11:4 bits of the instruction and Bit 25 (I) Bit 4 > 1 >> Reg shift 0 >> constent amount bits 6:5 > LSL 00 Logical shift left LSR 01 Logical shift right ASR 10 Arithmetic shift right ROR 11 Rotate right bits 11:7 > Shamt5 or Rs ( lower 8 bits of the register ) bit 25 >> enable the shift or n...
#include <bits/stdc++.h> using namespace std; #define INF 200000000000000000LL typedef long long int ll; typedef pair<ll,ll> ii; typedef pair<ii,ll> iii; typedef vector<ll> vi; typedef vector<ii> vii; #define getbit(n,i) (((n)&(1LL<<(i)))!=0) #define setbit0(n,i) ((n)&(~(1LL<<(i)))) #define setbit1(...
#include <bits/stdc++.h> using namespace std; long long n, m, q; long long gcd(long long a, long long b) { if (a < b) swap(a, b); if (b == 0) return a; return gcd(b, a % b); } int main() { cin >> n >> m >> q; long long v = gcd(n, m); long long innersize = n / v; long long outersize...
// // Copyright (c) 1999 Steven Wilson () // // This source code is free software; you can redistribute it // and/or modify it in source code form under the terms of the GNU // General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) // ...
/***************************************************************************** * File : processing_system7_bfm_v2_0_arb_hp0_1.v * * Date : 2012-11 * * Description : Module that arbitrates between RD/WR requests from 2 ports. * Used for modelling the Top_Interconnect switch. ************************...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
// /////////////////////////////////////////////////////////////////////////////////////////// // Copyright © 2011-2012, Xilinx, Inc. // This file contains confidential and proprietary information of Xilinx, Inc. and is // protected under U.S. and international copyright and other intellectual property laws. /////...
#include <bits/stdc++.h> using namespace std; int execute() { int n; cin >> n; string s; s.assign(n / 2 - 1, 1 ); if (n % 2) { cout << 7; } else { cout << 1; } cout << s << endl; return 0; } int TE = true; bool mTest = true; int main() { ios_base::sync_wi...
#include <bits/stdc++.h> using namespace std; const long long N = 4, M = 1e5 + 10, Mo = 1e9 + 7; long long n, m, nxt[M], p, lena, lenb, lens; string aa, bb, s; struct Matrix { long long n, a[N][N]; Matrix(long long _n = 4) { n = _n, memset(a, 0, sizeof(a)); } void operator~() { for (long lon...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2017/07/21 15:17:42 // Design Name: // Module Name: segDisplayDriver // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Tue Mar 28 02:26:33 2017 // Host : DESKTOP-B1QME94 running 64-bit major releas...
#include <bits/stdc++.h> using namespace std; char ch, B[1 << 20], *S = B, *T = B; long long aa, bb; long long rd() { while (ch = (S == T && (T = (S = B) + fread(B, 1, 1 << 20, stdin), S == T) ? 0 : *S++), !(ch >= 0 && ch <= 9 ) && ch != - ) ; ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; vector<vector<int> > g; bitset<(int)1e6> us; bool isCyclic(int v, int p = -1) { us.set(v); for (int i = 0; i < g[v].size(); i++) { if (us.test(g[v][i]) && g[v][i] != p) return 0; if (us.test(g[v][i])) continue; bool cures = isCyclic(g[v][i]...
//`timescale 1 ns / 100 ps module dv_embox(); parameter DW = 32; //Stimulus to drive reg clk; reg reset; reg mi_access; reg [19:0] mi_addr; reg [31:0] mi_data_in; reg mi_write; reg [1:0] test_state; reg go; //Reset initial begin ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2018 by Alex Solomatnikov. // SPDX-License-Identifier: CC0-1.0 interface hex2ram_if ( input bit trigger ); string instance_path = $sformatf("%m"); string testfil...
#include <bits/stdc++.h> using namespace std; int a[10], flag[200]; int main() { int sum = 0; for (int i = 1; i <= 5; i++) { cin >> a[i]; sum += a[i]; flag[a[i]]++; } int ans = sum; for (int i = 1; i <= 5; i++) { if (flag[a[i]] > 1 && flag[a[i]] < 4) ans = min(a...
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--){ //int n; cin >> n; string s; cin >> s; string res = ; for (int i=0;i<s.size();i++){ if (i%2==0){ if (s[i]== a ){ ...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: ff_jbi_sc0_1.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it and/...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N, M, Dx, Dy; cin >> N >> M >> Dx >> Dy; vector<pair<int, int>> way(N); way[0].first = way[0].second = 0; for (int i = 1; i < N; ++i) { way[i].first = (way[i - 1].first +...
#include <iostream> #include <vector> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <algorithm> #include <numeric> #include <queue> #include <iomanip> #include <numeric> #include <cmath> using namespace std; int main() { int t; cin >> t; f...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 200000 + 10; int n, m, k, nv; vector<pair<int, pair<int, int> > > edge; vector<pair<int, int> > e[maxn]; int f[maxn]; bool vis[maxn]; long long dis[maxn]; vector<long long> q; void print(int a[], int n, int ...
// (C) 1992-2014 Altera Corporation. All rights reserved. // Your use of Altera Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulati...
#include <bits/stdc++.h> using namespace std; int n; int values[400][400]; int mem[400][400][2]; void read() { cin >> n; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> values[i][j]; mem[i][j][0] = 0; mem[i][j][1] = 0; } } } void add(int x...
// (c) Copyright 1995-2019 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant ...
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; int n, q, a, b, blo, arr[N]; struct node { int a, b, id; } qq[N]; long long ans[N], dp[N]; bool cmp(node a, node b) { if (a.b != b.b) return a.b > b.b; return a.a < b.a; } int main() { scanf( %d , &n); blo = sqrt...
#include <bits/stdc++.h> using namespace std; template <typename T> void dbg(T a) {} template <typename T, typename... Arg> void dbg(T a, Arg... arg) {} const int maxn = (1e6) + 7; const int inf = (1e9) + 7; const long long LLinf = (1e18) + 7; const long double eps = 1e-9; const long long mod = 1e9 ...
#include <bits/stdc++.h> using namespace std; void fact(int n) { const int N = 1e5; vector<int> arr(N, 0); int q = 2; arr[0] = 1; int len = 1; int x = 0; int carry = 0; while (q <= n) { x = 0; carry = 0; while (x < len) { arr[x] = arr[x] * q + carry; ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2016/05/24 22:02:40 // Design Name: // Module Name: Register_with_synch_reset_load_behavior_tb // Project Name: // Target Devices: // Tool Versions: // Description: ...
#include <bits/stdc++.h> using namespace std; string s, t; int l[200005], r[200005], last[200005]; int main() { cin >> s >> t; memset(last, -1, sizeof(last)); int j = 0, slen = s.size(), tlen = t.size(); for (int i = 0; i < slen; i++) { l[i] = last[s[i] - a ]; if (j < tlen && s[i] =...
#include <bits/stdc++.h> using namespace std; int last[444444], pr[444444], p[444444], pred[444444]; string s[444444], t; int ans, n, len; void go(int v, int K) { int j = last[v]; while (j > 0) { int k = K, sz = s[j].length(); for (int q = 0; q < sz; q++) { while (k > 0 && s[j][q] ...
#include <bits/stdc++.h> using namespace std; int T, x; char str[100005], ans[100005]; char usd[100005]; int main() { scanf( %d , &T); while (T--) { scanf( %s , str + 1); scanf( %d , &x); int n = strlen(str + 1); for (int i = 1; i <= n; ++i) { if (str[i] == 0 ) { ...
#include <bits/stdc++.h> using namespace std; const long long inf = 1e10; void solve() { long long n, m, k; cin >> n >> m >> k; long long moves = (n + m - 2) + (n * m) - 1; for (long long i = 0; i < m + n; i++) { cin >> k; } cout << moves << n ; for (long long i = 0; i < n - 1;...
// phase_detector_filter.v module phase_detector_filter ( input clk, input reset, input update, input [3:0]phase_in, // 2*pi phase, half steps output [3:0]phase_out // 4*pi phase, full steps ); localparam N = 10; // must be >= 5 // --- phase adder register wire [(N-1):0]ph_cnt; // 4*pi phase assig...
// $Id: aeMB_regf.v,v 1.3 2007/11/10 16:39:38 sybreon Exp $ // // AEMB REGISTER FILE // // Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <> // // This file is part of AEMB. // // AEMB is free software: you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as // published ...
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3, Ofast , inline ) using namespace std; const long long mod = 1e9 + 7; const long long M = 1e8 + 5; const long long N = 6e5 + 5; char s[N]; bool check() { map<char, long long> mp; long long len = strlen(s + 1); long lon...
#include <bits/stdc++.h> using namespace std; const long long maxn = 3e5 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 7; const double eps = 1e-9; mt19937 rnd(time(0)); long long n; long long cnt[maxn]; struct state { long long a, b, d; state(long long a, long long b, long long d) : a(a), b(b), d...
// // Generated by Bluespec Compiler (build 0fccbb13) // // // Ports: // Name I/O size props // result_valid O 1 // result_value O 64 reg // CLK I 1 clock // RST_N I 1 reset // put_args_x_is_s...
#include <bits/stdc++.h> using namespace std; int a[1003][1003]; int r[1003]; int c[1003]; char ch[5]; int main() { int n, m, k; scanf( %d %d %d , &n, &m, &k); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf( %d , &a[i][j]); } } for (int i = 1; i <...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of inst_t_e // // Generated // by: wig // on: Mon Jun 26 16:51:35 2006 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl ../../open.xls // // !!! Do not edit this file! Autogenerated by MIX !!! // $Author:...
#include <bits/stdc++.h> using namespace std; const int maxn = 300100, mod = 998244353; inline void Add(int &a, int b) { a = a + b >= mod ? a + b - mod : a + b; } int head[maxn], nxt[maxn << 1], ver[maxn << 1], tot; inline void addedge(int a, int b) { nxt[++tot] = head[a]; ver[tot] = b; head[a] = ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2005 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; parameter [31:0] TWENTY4 = 24; parame...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int a[maxn], m, n, ans, dp[maxn]; inline bool check(int x) { memset(dp, 0, sizeof(dp)); for (int sta = 0; sta <= 1 && sta < n; sta++) { dp[sta] = sta ? max(a[0] + x, a[1]) : a[0]; for (int i = sta + 1; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; const int N = 50 + 7; int ned[N][N]; string s[N]; void paint(const vector<pair<int, int> > &v) { set<pair<int, int> > s; queue<pair<int, int> > que; map<pair<int, int>, int> cnt; for (auto e : v) { que.push(e); s.insert(e); } co...
// (c) Copyright 1995-2016 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant ...
#include <bits/stdc++.h> using namespace std; int n, k; int a[2000000]; int dem; int maxa; int dp[10000001]; void mmax(int &a, int b) { a = max(a, b); } bool ok(int len) { for (int i = 0; i <= maxa; i++) dp[i] = 0; dp[len] = 1; for (int i = len + 1; i <= maxa; i++) { mmax(dp[i], dp[i -...
#include <bits/stdc++.h> using namespace std; const int maxn = 1505; int n, a[maxn], sum[maxn], ans, val, ID; int d[maxn * maxn], cnt; vector<int> v[maxn * maxn]; vector<int> vv[maxn]; unordered_map<int, int> mp, L[maxn]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[...
/* * Copyright (c) 2002 Stephen Williams () * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU * General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * ...
#include <bits/stdc++.h> using namespace std; const int maxn = 333333; int ans[maxn]; int fa[maxn]; int nx[maxn]; int visit[maxn]; int n, m; inline int query(int a) { return a == fa[a] ? a : fa[a] = query(fa[a]); } inline void conbine(int a, int b) { a = query(a), b = query(b); if (a != b) fa[...
/* * Copyright (c) 2000 Stephen Williams () * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU * General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * ...
module mem (clk, wen, addr, in, out); parameter data_width = 32; parameter addr_width = 8; input clk; input wen; input [addr_width-1:0] addr; input [data_width-1:0] in; output [data_width-1:0] out; reg [...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 12:47:32 11/06/2013 // Design Name: // Module Name: i2s_out // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
//---------------------------------------------------------------------------- // Copyright (C) 2001 Authors // // This source file may be used and distributed without restriction provided // that this copyright statement is not removed from the file and that any // derivative work contains the original copyright notic...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; struct node { int a, b, id; bool operator<(const node& tem) const { return a > tem.a; } } vec[maxn]; bool used[maxn]; int n; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &vec[i].a); for (...
#include <bits/stdc++.h> using namespace std; const int MX = 102, md = 1000000007; int n, k, i, j, e, c[MX][MX], f[MX][MX * MX]; long long m, p[MX], q[MX]; bool ifq; long long pw(long long a, long long b) { if (b == 0) return 1LL; if (b & 1) return (a * pw(a, b - 1)) % md; long long x = pw(a, b ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; const long long oo = (long long)1e4; long long n, k; vector<pair<int, int> > l, r; int length(int x) { return x < 10 ? 1 : length(x / 10) + 1; } pair<int, int> checkWavy(int x) { if (x < 10) return make_pair(1, 0); int digits[8] = {x % 10, x / 10 % 10}, ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, h; string s; cin >> n >> s; m = (s[3] - 0 ) * 10 + s[4] - 0 ; if (m > 59) { s[3] = 0 ; } if (n == 24) { h = (s[0] - 0 ) * 10 + s[1] - 0 ; if (h > 23) { if (s[0] - 0 > 2) s[0] =...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 08:33:08 11/02/2013 // Design Name: // Module Name: sounds_module // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } map<vector<int>, int> S; for (int bit = 0; bit < (1 << 15); bit++) { vector<int> b(n); for (int i ...
`timescale 1ns / 1ps `define DEBUG // Output Left-Justified 24bit 192kHz 2ch (Stereo) Audio Stream module dac_drv( input wire clk, input wire rst, output wire bck_o, output wire data_o, output wire lrck_o, input wire [1:0] ack_i, input wire [23:0] data_i, output wire [1:0] pop_o); // 25...
`timescale 1ns / 1ps /* -- Module Name: Input Queue -- Description: Estructura FIFO. El modulo permite el intercambio de medio de almacenamiento. Por ejemplo, el uso del diseño registerFile_distRAM.v implementa un banco de registros que utiliza de manera exclusiva bloques de memoria distribuida en F...
#include <bits/stdc++.h> using namespace std; vector<int> mark[4]; string sins[4]; int cost[5]; int sta[1010]; int dp[1010][0xffff + 1]; int main() { int n; cin >> n; for (int i = 0; i < 4; i++) cin >> cost[i]; for (int i = 0; i < 4; i++) cin >> sins[i]; for (int j = 0; j < n; j++) { ...
#include <bits/stdc++.h> using namespace std; string a, b, p1 = Widget , p2 = VBox , p3 = HBox , ans[105]; map<string, int> q; vector<int> d[105]; int id[105]; long long l[105], r[105], h1[105], h2[105]; void dfs(int x) { if (l[x] != -1) return; l[x] = 0; for (int i = 0; i < (int)d[x].size(...
#include <bits/stdc++.h> using namespace std; int n; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; char ch; int Sum = 0, Count = 0; n /= 2; for (int i = 1; i <= n; i++) { cin >> ch; if (ch == 4 || ch == 7 ) { Count++; ...
/* Copyright 2018 Nuclei System Technology, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except i...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 256; const char nxt = n ; inline void in(string Q) { Q += .in ; freopen(Q.c_str(), r , stdin); } inline void out(string Q) { Q += .out ; freopen(Q.c_str(), w , stdout); } inline void open_file(string Q) { in(Q...
module so2par( input clk, input ym_so, input ym_sh1, input ym_sh2, input ym_p1, output reg [15:0] left, output reg [15:0] right, output reg [15:0] left_exp, output reg [15:0] right_exp, output update_left, output update_right ); reg [12:0] sreg; reg last_ym_sh1,last_ym_sh2; reg [15:...
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int ar[100000], br[10000]; memset(br, 0, sizeof(br)); for (long long int i = 1; i <= n; i++) { cin >> ar[i]; br[ar[i]]++; } sort(ar + 1, ar + n + 1); if (n == 1) { cout <...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int maxn = 200000 + 10; struct Tree { int tl, tr; int mx; } tree[maxn << 2]; set<int> st[maxn]; int ve[maxn], n, m; void build(int id, int l, int r) { tree[id].tl = l; tree[id].tr = r; tree[id].mx = -1; if (l == r) return; int...
#include <bits/stdc++.h> using namespace std; long long len(long long x, long long y) { return x * x + y * y; } long long scal(long long x1, long long y1, long long x2, long long y2) { if (x1 * y2 == x2 * y1) return -1; return x1 * x2 + y1 * y2; } bool in(long long x1, long long y1, long long x2, long...
#include <bits/stdc++.h> using namespace std; int n, q, p, p1, maxi, a[1000000], idx; stack<int> t, t1, id; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); maxi = -1; id.push(0); t.push(200000); t1.push(-1); for (int i = 1; i < n; i++) { p = 0; ...
// (C) 2001-2017 Intel Corporation. All rights reserved. // Your use of Intel Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulation // files), and any associated docum...
#include <bits/stdc++.h> using namespace std; const int N = 200 * 1000 + 5; vector<pair<int, int> > adj[N]; int w[N]; int d[N]; bool mark[N]; set<pair<int, int> > s; vector<int> ans; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> w[i]; } for (int ...
#include <bits/stdc++.h> using namespace std; const int maxN = 1e5 + 7; int n, m; vector<tuple<int, int, int>> res; vector<pair<int, int>> g[maxN]; bool blocked[maxN]; bool solve(int v, int pr = -1) { vector<int> unpaired; vector<int> adj; for (auto& to : g[v]) { if (!blocked[to.second])...
#include <bits/stdc++.h> class Counter { public: Counter(std::vector<size_t> perm1, std::vector<size_t> perm2) : size_(perm1.size()) { std::vector<size_t> inv2(size_, 0); for (size_t i = 0; i < size_; ++i) { inv2[perm2[i]] = i; } auto& points = perm1; for (size_t x...
module InstructionMemory(input clock, input clear, input[31:0] address, output [31:0] instr); reg[31:0] content[255:0]; integer i; always @(posedge clear, negedge clock) if (clear) begin // Reset content for (i = 0; i < 256; i = i + 1) content[i] = 0; // Initial values /* content[0] =...
#include <bits/stdc++.h> using namespace std; int main() { int m, n; cin >> m >> n; cout << (n * m) / 2 << n ; }
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; int mat[2 * 100001][26]; int n, k; int count3 = 0; void find_most(int x, int y) { int total = 0, mx = 0; for (int i = 0; i < 26; i++) { total += mat[x][i] + mat[y][i]; mx = max(mx, mat[x][i] + mat[y][i]); } count3 +...
#include <bits/stdc++.h> using namespace std; const int N = 201110; int lab[N], val[N]; vector<int> gr[N]; map<string, int> mp; int n, m, q; int root(int u) { if (lab[u] < 0) return u; else return lab[u] = root(lab[u]); } void join(int type, int u, int v) { if (lab[u] < lab[v])...
#include <bits/stdc++.h> using namespace std; int main() { long n; cin >> n; array<long, 2> a[n], b[n]; long i; for (i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; } for (i = 0; i < n; i++) { if (a[i][0] != a[i][1]) { cout << rated ; return 0; } } ...
// Code ok to distribute module autoasciienum_auto(); reg [2:0] /* auto enum sm_psm */ sm_psm; reg [2:0] /* auto enum sm_ps2 */ sm_ps2; localparam [2:0] // auto enum sm_psm PSM_IDL = 0, PSM_RST = 6, PSM_ZOT = 7; localpara...
// (C) 2001-2016 Intel Corporation. All rights reserved. // Your use of Intel Corporation's design tools, logic functions and other // software and tools, and its AMPP partner logic functions, and any output // files any of the foregoing (including device programming or simulation // files), and any associated docum...
#include <bits/stdc++.h> using namespace std; void solutionA(); int main() { ios_base::sync_with_stdio(false); solutionA(); return EXIT_SUCCESS; } long long n, a, b, u[1024]; double d[1024]; struct point { double x, y; point(double x = 0, double y = 0) : x(x), y(y) {} } s, f; struc...
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> string print_iterable(T1 begin_iter, T2 end_iter, int counter) { bool done_something = false; stringstream res; res << [ ; for (; begin_iter != end_iter and counter; ++begin_iter) { done_something = true; ...
/* Copyright (c) 2014 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute,...