text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { int n, temp; cin >> n; string s; cin >> s; temp = n; for (int i = n - 2; i >= 0; i--) { if (s.substr(i, 2) == 10 || s.substr(i, 2) == 01 ) { temp -= 2; s.erase(i, 2); i++; } } cout << te...
// (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 "register_set.v" `include "stimuli.v" `include "register_set_syn.v" `include "check.v" module register_set_tb(); // Wires logic [7:0] address; logic [31:0] data_in; logic [1:0] req; logic [2047:0] mem_out; logic [2047:0] mem_out_syn; logic ack, ack_syn, clk, reset, wnr; logic [31...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 100; int m, n; long long sweets[MAXN]; vector<long long> sol; long long weightedSum; long long sums[MAXN]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> sweets[i]; } sort(sweets, sweets + n); ...
#include <bits/stdc++.h> using namespace std; const int Inf = (int)1e9; const long long InfL = (long long)1e18; const int MaxN = (int)2e5 + 5; vector<int> adj[MaxN], ans; int n, a, deg[MaxN], dead[MaxN]; void dfs2(int x, int p) { dead[x] = true; ans.push_back(x); for (auto u : adj[x]) --deg[u]...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int a; cin >> a; string s; cin >> s; map<long long, long long> mp; long long ans = 0; for (int i = 0; i < s.size(); i++) { long long c = 0; for (int j = i; j ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int count = 0; int n, m; cin >> n >> m; char a[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } for (int i =...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. * ...
// DESCRIPTION: Verilator: Verilog Test module // // Copyright 2012 by Wilson Snyder. This program is free software; you can // redistribute it and/or modify it under the terms of either the GNU // Lesser General Public License Version 3 or the Perl Artistic License // Version 2.0. module t (/*AUTOARG*/); `define ASS...
#include <bits/stdc++.h> using namespace std; int heap(int a, int t) { int tmp; if (a > t) swap(a, t); if (t % a == 0) return a; return heap(a, t % a); } int main() { string x, y; cin >> x >> y; bool f = true; for (int i = 0; i < x.size(); i++) { if (x[i] != y[x.size() - 1 ...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of ent_t // // Generated // by: wig // on: Mon Oct 24 10:52:44 2005 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl -nodelta ../../verilog.xls // // !!! Do not edit this file! Autogenerated by MIX !!! //...
/** * 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; int main() { int q; cin >> q; while (q--) { string s; int n, s2 = 0, ans = 0, s1 = 0; cin >> s; n = s.size() - 1; for (int i = n; i >= 0; i--) if (s[i] == 1 ) { s2 = i; break; } for (in...
/** * 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 law...
/** * ------------------------------------------------------------ * Copyright (c) All rights reserved * SiLab, Institute of Physics, University of Bonn * ------------------------------------------------------------ */ `timescale 1ps/1ps `default_nettype none module bus_to_ip #( parameter BASEADDR = 0, ...
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 5; int n, ri[N]; char s[N]; struct node { int ch[26], par, val; } t[N]; int sz = 1, root = 1, last = 1; void extend(int c) { int p = last, np = ++sz; t[np].val = t[p].val + 1; ri[np]++; for (; p && !t[p].ch[c]; p = t[p...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 00:30:48 04/12/2016 // Design Name: // Module Name: Registro_timer // 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) 1999-2008 Easics NV. // 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 copyrigh...
#include <bits/stdc++.h> using llong = long long; using namespace std; set<llong> factors; void f(llong num) { factors.insert(1); llong to = sqrt(num); for (auto i = 2; i <= to; ++i) { if (num % i == 0) { factors.insert(i); factors.insert(num / i); } } factors.ins...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pi = pair<int, int>; void setIO(string name = ) { ios_base::sync_with_stdio(0); cin.tie(0); } int main() { setIO(); int a, b, c, d; cin >> a >> b >> c >> d; int pv = max(3 * a / 10, ...
/** * 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 N = 100005; vector<int> cnt[N]; int res[N]; int main() { int n; while (cin >> n) { for (int i = 1; i < N; i++) cnt[i].clear(); for (int i = 1; i <= n; i++) { int v; cin >> v; cnt[v].push_back(i); } ...
/* * Copyright (c) 2002 Jane Skinner * * 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) * any ...
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, x; cin >> n >> m >> x; x--; if (n > m) { cout << 0 << endl; return 0; } vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, 0)); ...
#include <bits/stdc++.h> using namespace std; const int V = 100000 + 5; int n, num[V]; int main() { int i, j; scanf( %d , &n); for (i = 0; i < n; ++i) scanf( %d , &num[i]); sort(num, num + n); printf( %d , num[n - 1]); for (i = 1; i < n - 1; ++i) printf( %d , num[i]); printf( %d n ...
module RAMB16_S2_S2( input WEA, input ENA, input SSRA, input CLKA, input [12:0] ADDRA, input [1:0] DIA, // input DIPA, // output [3:0] DOPA, output [1:0] DOA, input WEB, input ENB, input SSRB, input CLKB, input [12:0] ADDRB, input [1:0] DIB, // input DIPB, // output [3:0] DOPB, output [1...
#include <bits/stdc++.h> using namespace std; template <typename T> void dbg_vector(const T& v) { for (size_t i = 0; i < v.size(); ++i) cout << v[i] << ; cout << endl; } void dbg() { cerr << endl; } template <typename Head, typename... Tail> void dbg(Head H, Tail... T) { cerr << H << ; ...
/** * 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...
//----------------------------------------------- // This is the simplest form of inferring the // simple/SRL(16/32)CE in a Xilinx FPGA. //----------------------------------------------- `timescale 1ns / 100ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_simpl...
#include <bits/stdc++.h> using namespace std; int main() { int i, k; int n; cin >> n; if (n % 2 == 0) { k = n / 2; cout << k << n ; for (i = 0; i < k; i++) cout << 2 << ; } else { k = (n - 1) / 2; cout << k << n ; for (i = 0; i < k - 1; i++) { c...
#include <bits/stdc++.h> using namespace std; const long long N = 50; long long fac[N + 1]; void init() { fac[0] = 1; for (long long i = 1; i <= N; i++) { fac[i] = (i * fac[i - 1]) % 1000000007LL; } } long long pw(long long a, long long e) { if (e == 0) { return 1; } long...
#include <bits/stdc++.h> using namespace std; int n; long long int dp[3005][3005]; int a[3005]; int tree[3005 * 3005][2]; int cnt = 0; long long int check(int t) { return !((a[t - 3] == 0 && a[t - 2] == 0 && a[t - 1] == 1 && a[t] == 1) || (a[t - 3] == 0 && a[t - 2] == 1 && a[t - 1] == 0 &...
module test; initial begin: A reg [4:0] a; reg [31:0] b, c, d; a = 5'h14; b = $signed(a); c = {_$Finv5(_$Fsub8(_$Fadd8((32'haa ^ (32'hcc & _$Fsll32(_$Fsrl32(_$Fsll32(32'h78, 32'h2), 32'h3), 32'h1))), 32'h69), (32'h50 * 32'h2)))}; d = $signed(_$Finv5(_$Fsub8(_$Fadd8((32'haa...
#include <bits/stdc++.h> const int p10[7] = {1, 10, 100, 1000, 10000, 100000, 1000000}; int N, S[10], can_be_zero[10], L, p[10], fill[10], O; char a[7]; int main() { for (int i = 0; i < 10; i++) can_be_zero[i] = 1; scanf( %d , &N); for (int i = 0; i < N; i++) { scanf( %s , a); L = 0; ...
//bug844 module device( input clk, output logic [7:0] Q, out0, output logic pass, fail input [7:0] D, in0,in1 ); enum logic [2:0] {IDLE, START, RUN, PASS, FAIL } state, next_state; logic ready, next_ready; logic next_pass, n...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Wed Mar 01 09:54:25 2017 // Host : GILAMONSTER running 64-bit major release (...
// --------------------------------------------- // external memory controller // --------------------------------------------- // The CPU runs at ~50MHz (20ns) // // When accessing byte-wide external memory, sufficient wait states // need to be added to allow two slower memory cycles to happen // (low byte then high ...
#include <bits/stdc++.h> using namespace std; const long dad = 1e6; int n, m, l = 1, r; long long k; long long d[dad], a[dad], b[dad], res, ans[dad], dem[dad]; struct yasu { int id, l, r; } p[dad], c[dad]; bool cmp(yasu u, yasu v) { return (u.l / 300 < v.l / 300 || (u.l / 300 == v.l / 300 && u.r...
/** * 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> #pragma comment(linker, /STACK:100000000 ) using namespace std; const long double pi = acos(-1.0); const long long inf = (long long)1e18; const int N = (int)1e6; int n, m; long long need[N], start[N]; bool check(long long x) { int lowest = 0; for (int i = 0; (i < n) && ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a = min(m, n); if (a % 2 == 0) { cout << Malvika ; } else { cout << Akshat ; } return 0; }
#include <bits/stdc++.h> using namespace std; template <typename _T> inline void read(_T &f) { f = 0; _T fu = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) fu = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { f = (f << 3) + (f << 1) + (c & 15); ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2014 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; function int f_no_no (); int st = 2; st++; return st; endfunction function int f_...
/* * 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; string w = RPS ; string s; int t[4], n, m, a[105], ans[105]; int main() { ios::sync_with_stdio(0); int Q; cin >> Q; while (Q--) { memset(ans, 0, sizeof(ans)); cin >> n >> t[1] >> t[2] >> t[3] >> s; m = (n + 1) / 2; for (in...
/** * 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 mod = 1e9 + 7; const int inf = 0x3f3f3f3f; long long gcd(long long x, long long y) { if (y == 0) return x; else return gcd(y, x % y); } long long ksm(long long a, long long b) { long long r = 1; while (b) { if (b & 1) ...
#include <bits/stdc++.h> using namespace std; void solve() { int n, ans = 0; cin >> n; long long int ar[n]; for (int i = 0; i < n; i++) { cin >> ar[i]; } sort(ar, ar + n); long long int s = 0; for (int i = 0; i < n; i++) { if (s <= ar[i]) { s += ar[i]; ans...
#include <bits/stdc++.h> using namespace std; long long labs(long long a) { return a < 0 ? (-a) : a; } long long max(long long a, long long b) { return a > b ? a : b; } long long min(long long a, long long b) { return a < b ? a : b; } const int MAXN = 1005; const int UNDEF = -1; const int IMPOS = INT_MAX ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int t; cin >> t; while (t--) { int a, b, c, d; cin >> a >> b >> c >> d; cout << max(a + b, c + d) << n ; } return 0; }
#include <bits/stdc++.h> using namespace std; int n, m, q, num, tot, tp, cnt, ans, w[200100], head[200100], dfn[200100], c[200100], low[200100], sta[200100]; int dfc, sz[200100], d[200100], f[200100], son[200100], top[200100], tree[200100], mn[200100 * 4]; vector<int> v[200100]; multiset<int> s[20...
#include <bits/stdc++.h> using namespace std; const int INF = INT_MAX; const signed long long int LINF = LLONG_MAX; const double EPS = 1e-9; const int MOD = 1000000007; const int MAXN = 100001; const int ALPH = 26; const int DALPH = 52; string s; vector<int> z; vector<pair<int, int> > ans; vecto...
#include <bits/stdc++.h> using namespace std; int main() { int n, p; cin >> n >> p; string s; cin >> s; if (p > s.length() / 2) { reverse(s.begin(), s.end()); p = (n - p) + 1; } int sum = 0; int t[n], l = -1, r = 0; for (int i = 0; i < s.length() / 2; i++) { if ...
/*this module will realise the 8 Registers the processor provides. Tofu tries not to create a bus system. The Idea is to hardwire everything, this will prevent floating wires. */ module regbank (addr1, addr2, addrdest, data1, data2, datadest, control, enable); input wire [2:0] addr1, addr2, addrdest, datadest; output w...
module fifo_TB; reg clk; reg reset; reg rd; reg wr; reg[7:0] dataint; fifo uttf(.rd(rd),.wr(wr),.din(dataint),.clock(clk),.reset(reset)); always begin clk =1'b1; #10; clk=1'b0; #10; end initial begin reset = 1'b1; #4 reset = 1'b0; end initial begin wr = 1'b0; #3430; wr=1'b1; #34300; wr = 1'b0; #34300; /*wr = 1'...
#include <bits/stdc++.h> using namespace std; char s[10]; int n; int notzero[12], cnt[12], ten[10], ans; int main() { ten[0] = 1; for (int i = 1; i < 8; ++i) ten[i] = 10 * ten[i - 1]; scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %s , s); int len = strlen(s); notzero...
#include <bits/stdc++.h> using namespace std; template <class T> void show(T a, int n) { for (int i = 0; i < n; ++i) cout << a[i] << ; cout << endl; } template <class T> void show(T a, int r, int l) { for (int i = 0; i < r; ++i) show(a[i], l); cout << endl; } const int N = 20; const...
/** * 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 mod = 1e9 + 7; int n, x[5000 + 5], y[5000 + 5], tot; int color[5000 + 5]; bool flag; int ksm(int b, int k) { int s = 1; while (k > 0) { if (k & 1) s = (1ll * s * b) % mod; k >>= 1; b = (1ll * b * b) % mod; } return s %...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << ? << ; fflush(stdout); for (int i = 0; i < 100; i++) { cout << i << ; fflush(stdout); } cout << endl; int n; cin >> n; c...
#include <bits/stdc++.h> using namespace std; int n, v0, f[200012], nu = 0; struct eve { int x, v, l; inline bool operator<(const eve &b) const { return (x < b.x) || ((x == b.x) && (v < b.v)); } }; multiset<eve> s; inline void cha(int x, int v) { f[x] = v; if (v + v0 <= 1e9) s.inse...
/** * 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; int main() { int s, k; cin >> k >> s; while (s >= 1) { for (int i = 1; i <= k; i++) { if (s >= i) { s = s - i; } else { cout << s << endl; return 0; } } } cout << s << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using D = double; using uint = unsigned int; const int maxn = 100005; ll t[maxn], others[maxn], me[maxn]; int f[maxn]; vector<int> from[maxn]; int kv[maxn]; ll ans[maxn]; int n, m; multiset<ll> global; ...
//------------------------------------------------------------------------------ // (c) Copyright 2013-2015 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 propert...
#include <bits/stdc++.h> using namespace std; int n, k; int ok(double x, double a[]) { double z1 = 0, z2 = 0; for (int i = 0; i < n; i++) { if (x - a[i] > 0) { z1 += x - a[i]; } if (x - a[i] < 0) { double ans = 1 - (k * (double)1) / 100; z2 += (a[i] - x) * ans; ...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: nine_new2.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ==========================...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: tx_valid_fifo.v // Megafunction Name(s): // dcfifo // // Simulation Library Files(s): // altera_mf // =============================...
#include <bits/stdc++.h> using namespace std; int main() { int n1, n2, k, a; cin >> n1 >> n2; vector<int> arr1, arr2; for (int l = 0; l < n1; l++) { cin >> a; arr1.push_back(a); } for (int l = 0; l < n2; l++) { cin >> a; arr2.push_back(a); } sort(arr1.begin(),...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 5e5 + 10; vector<int> v[31]; long long par[31], X[31], Y[31], vis[31]; int xxx = 31; void bfs() { queue<tuple<int, int, int>> qu; qu.push(make_tuple(1, 0, xxx)); vis[1] = 1; X[1] = Y[1] = 1ll << xxx; w...
#include <bits/stdc++.h> using namespace std; const int maxN = 1000 + 5; const int mod = 1000 * 1000 * 1000 + 7; int a[65], b[65]; int main() { ios_base::sync_with_stdio(false); long long l, r; cin >> l >> r; for (int i = 0; l > 0; l /= 2, i++) a[i] = l % 2; for (int i = 0; r > 0; r /= 2, ...
#include <bits/stdc++.h> using namespace std; int main() { int n, SF, FS; SF = FS = 0; string flights; cin >> n >> flights; for (int i = 0; i < flights.size() - 1; i++) { if (flights[i] == S && flights[i + 1] == F ) { SF++; } else if (flights[i] == F && flights[i + 1] ==...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////// // File name : sata_test_top.v // Note : This is the top module which connects SATA controller, // Microblaze System and SATA test logic. // Test/Verification Environment // Dependencies ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2011 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc = 0; reg [63:0] crc; ...
/* * 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; bool comp(long long a, long long b) { if (a > b) return true; else return false; } int isP(long long n) { if (n == 1) return 0; if (n == 2 || n == 3) return 1; for (long long i = 2; i <= sqrt(n); i++) { if (n % i == 0) return 0;...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2007 Corgan Enterprises LLC // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of...
#include <bits/stdc++.h> using namespace std; int n, deg[51]; long long dp[2][51][51][51][51]; inline void add(long long &a, long long b) { a += b; } void transition3(int b, int p1, int p2, int c1, int c2) { long long from = dp[b][p1][p2][c1][c2] % 1000000007; b ^= 1; if (p1 > 0) add(dp[b][p1 - 1]...
#include <bits/stdc++.h> using namespace std; const int N = 1e6; int d[2 * N], c[2 * N], n, k, l, p, a = N, q, w, u; string s; int main() { cin >> n >> k >> l >> s; q = 0; w = N; while (q < w) { p = (q + w) >> 1; for (int i = n - 1; i >= 0; i--) { d[i] = d[i + 1] + (s[i] > ...
/* * 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 a[1000050]; vector<int> vec[1000050]; int pos[1000050]; int main() { int n, x; scanf( %d%d , &n, &x); for (int i = 0; i < n; i++) { scanf( %d , a + i); vec[a[i]].push_back(i); } pos[x + 1] = n; int st = 1; for (int i = x...
/* Copyright (c) 2016-2018 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, distri...
#include <bits/stdc++.h> using namespace std; const int maxn = 501; int dp[maxn][maxn]; int n; int a[maxn]; int dp2[maxn]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i], dp[i][i] = a[i]; for (int len = 1; len <= n; len++) { for (int i = 1; i <= n - len + 1; i++) { ...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: Grid.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ===============================...
#include <bits/stdc++.h> using namespace std; template <class S, class T> ostream& operator<<(ostream& st, pair<S, T> p) { st << ( << p.first << , << p.second << ) ; return st; } template <class T> ostream& operator<<(ostream& st, vector<T> v) { st << [ ; for (size_t i = 0; i < v.size(...
/** * 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...
// -*- Mode: Verilog -*- // Filename : wb_dsp_equations_top.v // Description : Container for all Equations // Author : Philip Tracton // Created On : Wed Jan 13 16:34:33 2016 // Last Modified By: Philip Tracton // Last Modified On: Wed Jan 13 16:34:33 2016 // Update...
// Double buffering with dual-port RAM // Uses single-port RAM to write switches to a section while reading from the same section to control LEDs, // so each switch acts as if connected directly to the corresponding LED. // Flip SW0 to change sections. module top ( input clk, input [15:0] sw, ...
/* * 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<iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int a; cin >> a; cout << 2-a*a; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n], sm = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sm += a[i]; } vector<int> ind, r; int need = sm / 2; if (a[0] > need) { cout << 1 << endl; cout << 1; return 0; }...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; string s[n]; for (int i = 0; i < n; i++) cin >> s[i]; vector<vector<int>> row(n), col(m); for (int i = n - 1; i >= 0; i--) { for (int j = 0; j < m; j++) { if (s[i][j] == # ) { row[i]....
// file: timer_tb.v // // (c) Copyright 2008 - 2010 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 ...
/** * 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 MAX_N = 200000; int ans[MAX_N + 5]; int main() { int tc; cin >> tc; while (tc--) { int n, i, j; string s; cin >> n >> s; int num = n, last = 0; for (i = 0; i < n; i++) { if (i == n - 1 || s[i] == > ) { ...
#include <bits/stdc++.h> using namespace std; const int N = 1003; int n, k; bitset<N * 3> A, dp, dpt; int main() { scanf( %d%d , &n, &k); for (int a; k; k--) scanf( %d , &a), A[a] = 1; dp[1500] = 1; for (int __ = 1; __ <= 1009; __++) { dpt = 0; for (int i = 0; i < 3000; i++) ...
#include <bits/stdc++.h> using namespace std; int main() { int n; string digit[10] = { , one , two , three , four , five , six , seven , eight , nine }; string tenth[10] = { , ten , twenty , thirty , forty , fifty , sixty , ...
// Memory controller to access TVM VPI simulated RAM. // // You only see the wires and registers but no logics here. // The real computation is implemented via TVM VPI // // Usage: create and pass instance to additional arguments of $tvm_session. // Then it will be automatically hook up the RAM logic. // module tvm_vp...