text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } long long f[2001], dp[2001][2001], m = 998244353; long long fun(long long i, long long...
/** * 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 dr[] = {-1, 0, 1, 0, -1, 1, 1, -1}; int dc[] = {0, 1, 0, -1, 1, 1, -1, -1}; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; while (cin >> n) { vector<int> arr; int st = 1; int ans = 0; for (int i = (0); i <= (2 * ...
`include "params.v" `define INCLUDE_PARAMS `include "ISA.v" `define INCLUDE_ISA // include modules `include "IMem.v" `define INCLUDE_IF_MOD `include "IF.v" `include "IF_ID.v" `include "Reg.v" `define INCLUDE_ID_MOD `include "ID.v" `include "ID_EXE.v" `define INCLUDE_EXE_MOD `include "EXE.v" `include "EXE_MEM.v"...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; const int mod = 1e9 + 7; const int inf = 0x3f3f3f3f; int a1[maxn], a2[maxn]; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, k; cin >> n >> k; long long ans = (n + 1) * n / 2; for (int i = 1; ...
#include <bits/stdc++.h> using namespace std; long long gcd(long long n, long long m) { return m == 0 ? n : gcd(m, n % m); } long long lcm(long long n, long long m) { return (m * n) / gcd(n, m); } long long dx[] = {1, 0}; long long dy[] = {0, 1}; const long long inf = 1e9 + 10; const long long INF = 1e18;...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; const long long mod = 1e9 + 7; struct node { int s, e, next; } edge[maxn]; int head[maxn], len; void add(int s, int e) { edge[len].e = e; edge[len].next = head[s]; head[s] = len++; } void init() { memset(head,...
/* * 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...
#include <bits/stdc++.h> using namespace std; int n, p; int sum, mx; vector<int> ans; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = (1); i <= (n); i++) { if (i == 1) { cin >> p; ans.push_back(1); sum += p; ...
#include <bits/stdc++.h> using namespace std; using LL = long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int T; vector<int> f(3e5 + 5); f[0] = 0; for (int i = 1; i < 3e5 + 5; i++) f[i] = f[i - 1] ^ i; for (cin >> T; T; T--) { int a, b; cin >> a >> b; int...
/*============================================================================ This Verilog source file is part of the Berkeley HardFloat IEEE Floating-Point Arithmetic Package, Release 1, by John R. Hauser. Copyright 2019 The Regents of the University of California. All rights reserved. Redistribution an...
#include <bits/stdc++.h> using namespace std; ifstream F( p.in ); const int M = 1000000007; const int K = 110; const int N = 100100; int dp[K][N], b[N], c[N][K]; int n, m; void add(int &x, int y) { x = ((x + y) % M + M) % M; } int main() { ios::sync_with_stdio(0); for (int n = 0; n < N; ++n) {...
`timescale 1ns/1ns module udp_rx_joint_cmd (input c, input [7:0] rxd, input rxdv, output [7:0] mode, output [31:0] tgt_0, output [31:0] tgt_1, output [31:0] tgt_2, output [31:0] control_id, output cmd_valid); // by the time the data stream gets here, it is already known-valid. // regi...
// (C) 2001-2016 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 simulation // files), and any associated doc...
#include <bits/stdc++.h> using namespace std; int main() { string cad; int cnt = 0, ans = 0; cin >> cnt >> cad; cnt = 0; for (int i = 0; i < cad.size(); i++) { if (cad[i] == x ) { cnt++; } else { ans += max(0, cnt - 2); cnt = 0; } } ans += max(0...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 1e-6; const int inf = 1e9; const long long llf = 1e18; const int mod = 1e9 + 7; const int maxn = 1e5 + 10; char s[110]; int f[310]; int main() { int tc; cin >> tc; while (tc--) { cin >> s...
/** * 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) 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) // ...
#include <bits/stdc++.h> using namespace std; double mar[100000]; int main() { double ml, rl; cin >> ml >> rl; double m = ml, r = rl; double save = 0; if (ml >= 3) save += 2 * m * (m - 3) + 2 * (m - 2) + 6; else if (ml == 2) save += 2; save *= (sqrt(2) - 2); double ans ...
#include <bits/stdc++.h> template <typename T> inline T max(T a, T b) { return a > b ? a : b; } template <typename T> inline T min(T a, T b) { return a < b ? a : b; } template <typename T> inline T abs(T a) { return a > 0 ? a : -a; } template <typename T> inline void repr(T &a, T b) { ...
#include <bits/stdc++.h> using namespace std; const int LEN = (int)1e5; int n; long long a[LEN]; vector<int> g[60]; int bfs(int r, int t) { queue<int> q; static int d[LEN]; memset(d, 0, sizeof d); q.push(r); d[r] = 1; while (!q.empty()) { int u = q.front(); q.pop(); ...
#include <bits/stdc++.h> using namespace std; signed main() { std::ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); ; long long CASE = 1; while (CASE--) { long long n; cin >> n; vector<std::pair<long long, long long> > c; for (long long i = 0; i < n; ++i) { ...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string s; cin >> s; stack<char> stack; int left = 0, right = 0, size = 0; for (int i = 0; i < s.length(); i++) { stack.push(s[i]); if (s[i] == ( ) { left++; continue; } ...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int lens = s.length(); s = + s; s = s + ; int minn = -1; int a[10000] = {0}; a[0] = 0; int p = 1; for (int i = 0; i <= lens + 1; i++) { if (s[i] == A || s[i] == E || s[i] == I ||...
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)1e18; const int mod = (int)1e9 + 7; const int MAXN = (int)4e5 + 5; long long n, ans[MAXN], ext[MAXN]; vector<pair<int, pair<int, int>>> sorg[MAXN]; vector<pair<int, int>> adj[MAXN]; int a[MAXN]; const int L = 20; int geri...
// DESCRIPTION: Verilator: Verilog Test module // // A test case for struct signal bit selection. // // This test is to check that bit selection of multi-dimensional signal inside // of a packed struct works. Currently +: and -: blow up with packed structs. // // This file ONLY is placed into the Public Domain, for any...
#include <bits/stdc++.h> using namespace std; int a[5], r[5] = {0, 2, 3, 4, 1}; int main() { for (int i = 1; i <= 4; i++) scanf( %d , &a[i]); for (; a[1] != 1 || a[2] != 1 || a[3] != 1 || a[4] != 1;) { int x = rand() % 4 + 1; if (a[x] == 1 && a[r[x]] == 1) continue; if ((a[x] % 2 == 0) &...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long a[3], d, ans = 0; cin >> a[0] >> a[1] >> a[2] >> d; sort(a, a + 3); if (a[1] - a[0] < d) ans += (d - (a[1] - a[0])); if (a[2] - a[1] < d) ans += (d - (a[2] ...
/** * 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...
// -------------------------------------------------------------------------------- //| Avalon Streaming Channel Adapter // -------------------------------------------------------------------------------- `timescale 1ns / 100ps module lab3_master_0_p2b_adapter ( // Interface: clk input cl...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:64000000 ) using namespace std; const int infi = 1e9 + 7; const long long infl = 1e18 + 7; int ar[101]; bitset<101> dp0[10500]; bitset<101> dp[10500]; bitset<101> ndp[10500]; int main() { cin.sync_with_stdio(false); cin.tie(0); int n...
#include <bits/stdc++.h> using namespace std; int n, k; char s[1000111]; pair<int, int> q[33]; int a[33]; int main() { scanf( %d%d n , &n, &k); gets(s); int l = strlen(s); for (int i = 0; i < k; i++) q[i].second = i; long long sum = 1; for (int i = 0; i < l; i++) { int u = s[i]...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); unordered_map<int, int> ma; int x, y, z, l; cin >> x >> y; vector<int> vec(x); vector<int> vec1(x); for (int i = 0; i < x; i++) cin >> vec[i]; vec1 = vec; for (int...
// Copyright 1986-2015 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2015.4 (lin64) Build Wed Nov 18 09:44:32 MST 2015 // Date : Sat Aug 27 18:41:24 2016 // Host : fpgaserv running 64-bit Ubuntu 14.04.4 LTS ...
#include <bits/stdc++.h> using namespace std; int solve(string &s) { int len = s.length(); int ret = 0; for (int i = 0; i < len; ++i) { if (s[i] == V && i + 1 < len && s[i + 1] == K ) { ++ret; } } return ret; } int main() { string s; while (cin >> s) { in...
#include <bits/stdc++.h> using namespace std; long long s[100007]; long long l[100007]; int main() { long long n, k, r = 0; cin >> n >> k; map<int, int> m; map<int, int> e[10]; long long ki = 0; for (int i = 0; i < n; i++) { scanf( %I64d , &s[i]); r += s[i] / 10; if (s[...
#include <bits/stdc++.h> using namespace std; const int mxN = 1e6 + 5; vector<int> adj[mxN]; int n, m, sz[mxN], dp[mxN], dpb[mxN], mn[mxN]; bool bad[mxN]; int ans = 1e9 + 7, V; void dfs1(int v, int par = -1) { sz[v] += bad[v]; for (auto to : adj[v]) { if (par != to) { dfs1(to, v); ...
// // 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) // ...
#include <bits/stdc++.h> using namespace std; int n, k, v[105], frec[105]; vector<int> ans; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 1; i <= n; i++) if (!frec[v[i]]) { frec[v[i]] = 1; ans.push_back(i); if (ans.size() == k) break...
/////////////////////////////////////////////////////////////////////////////// // // Project: Aurora Module Generator version 2.8 // // Date: $Date: 2007/09/28 12:50:36 $ // Tag: $Name: i+HEAD+134158 $ // File: $RCSfile: standard_cc_module.ejava,v $ // Rev: $Revision: 1.2...
#include <bits/stdc++.h> using namespace std; inline long long getint() { long long num = 0, flag = 1; char c; while ((c = getchar()) < 0 || c > 9 ) if (c == - ) flag = -1; while (c >= 0 && c <= 9 ) num = num * 10 + c - 48, c = getchar(); return num * flag; } int n, m, q, R; i...
`include "riscv_functions.vh" module riscv_mem ( input clk, input rstn, //EX input input ex_mem_rdy, output ex_mem_ack, input ex_mem_alu_op, input [31:0] ex_mem_st_data...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e4 + 42; int n, m, k; int d[55][maxn], dp[55][maxn], s[55][maxn]; int val[maxn << 2], tag[maxn << 2]; int g; void build(int day, int l, int r, int rt) { if (l == r) { val[rt] = dp[day][l] + s[day + 1][l + k - 1] - s[day + 1][l - 1];...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const int maxn = 20005; const long long Mod = 998244353; using namespace std; int n, m, k; int a[60][maxn], sum[60][maxn], dp[60][maxn]; int mx[maxn << 2], lazy[maxn << 2]; void pushup(int rt) { mx[rt] = max(mx[rt << 1], mx[rt <...
/* * 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...
`default_nettype none module \$alu (A, B, CI, BI, X, Y, CO); parameter A_SIGNED = 0; parameter B_SIGNED = 0; parameter A_WIDTH = 1; parameter B_WIDTH = 1; parameter Y_WIDTH = 1; parameter _TECHMAP_CONSTMSK_CI_ = 0; parameter _TECHMAP_CONSTVAL_CI_ = 0; (* force_downto *) input [A_WIDTH-1:0] A; (* force_downto *) inp...
#include <bits/stdc++.h> using namespace std; long long n, a, b, ans; vector<long long> v[100005]; vector<long long> res; long long cost(long long num) { res.clear(); long long sum = 0; long long need = num - v[0].size(); for (long long i = 1; i <= 100000; i++) { for (long long j = 0; j ...
/** * 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...
/*************************************************************************************************** ** fpga_nes/hw/src/cpu/apu/apu_length_counter.v * * Copyright (c) 2012, Brian Bennett * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted * provi...
#include <bits/stdc++.h> using namespace std; int a, s, d[10004][2], f, g, h, j, k, l, i, n, m; string x, z; set<string> q; bool chk(int idx, int dis) { for (int i = idx; i < idx + dis; i++) { if (x[i] != x[i + dis]) return true; } return false; } int main() { cin >> x; n = x.siz...
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_b_channel.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_...
/* * 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 the License, or * (at your option) any later version. * * This program is distributed in the hope that it wi...
#include <bits/stdc++.h> using namespace std; vector<int> v; int main() { long long p, k; cin >> p >> k; while (p) { long long y = p % k; if (y < 0) y += k; v.push_back(y); p -= y; p /= k; p *= -1; } cout << v.size() << endl; for (int i = 0; i < v.size()...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: FIFO_16_256.v // Megafunction Name(s): // dcfifo // ============================================================ // ********************...
#include <bits/stdc++.h> using namespace std; using LL = long long; const int maxn = 3000010; int n, b; int pre[maxn], vis[maxn]; vector<int> prime; struct init { init() { memset(pre, 0, sizeof pre); prime.clear(); for (int i = 2; i < maxn; i++) { if (pre[i] == 0) { ...
// megafunction wizard: %LPM_COUNTER%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: LPM_COUNTER // ============================================================ // File Name: twentyonecounter.v // Megafunction Name(s): // LPM_COUNTER // // Simulation Library Files(s): // lpm // =======================...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 11; int n, m; int cha[N], fa[N]; int dfn[N], tot, sz[N]; int U, V; int head[N], nex[N << 1], to[N << 1], size = 1; bool vis[N << 1]; int fr[N]; int dl[N], zh[N], tp; void add(int x, int y) { to[++size] = y; nex[size] = head[...
(* Copyright © 1998-2006 * Henk Barendregt * Luís Cruz-Filipe * Herman Geuvers * Mariusz Giero * Rik van Ginneken * Dimitri Hendriks * Sébastien Hinderer * Bart Kirkels * Pierre Letouzey * Iris Loeb * Lionel Mamane * Milad Niqui * Russell O’Connor * Randy Pollack * Nickolay V. Shmyrev * Bas Spitters * ...
module io1_sub( /*AUTOARG*/); wire [42:0] bscan_data; // boundary scan stitch parameter bscan_count = 0; assign bscan_data[0] = bscan_in; /* * Emacs template to auto instaniate MD[31:0] pads */ /* autoinst_lopaz_srpad AUTO_TEMPLATE ( .pin(MD[@])...
#include <bits/stdc++.h> using namespace std; int n, m, q; int p[200001]; int a[200001]; vector<int> cur[200001]; int pos[200001]; int par[200001][21]; struct cmp { bool operator()(pair<int, int> a, pair<int, int> b) { return a.second > b.second; } }; priority_queue<pair<int, int>, vec...
/* * 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 int maxn = 1e6 + 10; int awsl[maxn]; int main() { int n; scanf( %d , &n); string s; cin >> s; vector<int> sum(n); vector<int> m(n); for (int i = 0; i < n; ++i) { if (s[i] == ( ) awsl[i] = 1; else awsl[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...
/////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2014 Francis Bruno, All Rights Reserved // // 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 Found...
#include <bits/stdc++.h> #pragma GCC optimize(3, Ofast , inline ) #pragma GCC target( avx,avx2 ) using namespace std; template <class t> inline t read(t &x) { char c = getchar(); bool f = 0; x = 0; while (!isdigit(c)) f |= c == - , c = getchar(); while (isdigit(c)) x = (x << 1) + (x << ...
#include <bits/stdc++.h> using namespace std; int n, t, k, x; string s; int main() { cin >> s; n = s.size(); for (int k = 0;; k++) { if (s[k] == . ) { t = k; break; } } if (s[t - 1] == 9 + 0 ) cout << GOTO Vasilisa. ; else if (s[t + 1] < 5 + 0 ) { ...
#include <bits/stdc++.h> using namespace std; bool judge(char c) { if (c == a || c == e || c == i || c == o || c == u || c == y ) return false; else return true; } int main() { char a[110]; int n, m = 0; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (i...
#include <bits/stdc++.h> using namespace std; string gd, str, ask; int q, n, t, ans, tmp, cnt, ara[1000]; int main() { cin >> gd >> str >> n; for (int i = 0; i < gd.size(); i++) ara[gd[i] - a ] = 1; while (n--) { cin >> ask; int in = -1, fin = -1; ans = 0; for (int i = 0; i ...
//----------------------------------------------------- // This is FSM demo program using always block // Design Name : fsm_using_always // File Name : fsm_using_always.v //----------------------------------------------------- module fsm_using_always ( clock , // clock reset , // Active high, syn reset req_...
/** * 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 inf = 0x3f3f3f3f; const int mod = 1e9 + 7; int n, a[500010], b[500010], c[500010], bit[500010]; void init() { for (int i = 1; i <= n; i++) { bit[i] = 0; } } int lowbit(int x) { return x & (-x); } void add(int u, int x) { for (; u ...
module scaler_spliter # ( parameter integer C_S_WIDTH = 12, parameter integer C_M_WIDTH = 12, parameter integer C_S_BMP = 0 , parameter integer C_S_BID = 0 , parameter integer C_S_IDX = 0 , /// C_S_WIDTH or 0 parameter integer C_SPLIT_ID_WIDTH = 2, parameter integer C_TEST = 0 ) ( input wire clk, inpu...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d%d , &n, &m); queue<int> x, y; for (int i = 0; i < n; ++i) { int tmp; scanf( %d , &tmp); x.push(tmp); } for (int i = 0; i < m; ++i) { int tmp; scanf( %d , &tmp); y.push(tmp); ...
#include <bits/stdc++.h> using namespace std; vector<long long int> a, v, val; long long int n, x; long long int eval(long long int d, long long int i) { if ((d + x - 1) <= a[i]) { long long int ans = ((d + x - 1) * (d + x)) / 2 - ((d - 1) * (d)) / 2; return ans; } else { long long int...
#include <bits/stdc++.h> using namespace std; int n, x, y, m, nr, nr1, st, dr, i, j, z, p1, p2, aux, a[1004], b[1004], s[1004], d[1004]; bool ok, c[1004]; int main() { scanf( %d %d %d , &n, &x, &y); ok = true; y = 1; s[1] = 1; d[1] = n; while (ok == true) { nr1 = 0; nr ...
#include <bits/stdc++.h> using namespace std; vector<long long> g[100000 + 10]; map<pair<long long, long long>, long long> mp; map<long long, pair<long long, long long> > road; long long cnt[100000 + 10]; long long ans = 0; int visited[100000 + 10]; int L[100000 + 100]; long long n; void dfs(long lo...
/** * 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 n, maxi[((int)101 * 1000) / ((int)350) + 1000], fnsh, id[((int)101 * 1000)], ex[((int)101 * 1000)]; vector<int> v[((int)101 * 1000) / ((int)350) + 1000]; void reset() { int num = 0; for (int i = 0; i < fnsh; v[i].clear(), v[i].resize(0), i++) ...
#include<bits/stdc++.h> using namespace std; #ifdef LOCAL #include debug.h #endif #ifdef LOCAL #define debug(...) cerr << [ << #__VA_ARGS__ << ]: , debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif #define endl n typedef long long ll; typedef long double ld; typedef ve...
#include <bits/stdc++.h> using namespace std; mt19937_64 random_num( chrono::high_resolution_clock::now().time_since_epoch().count()); const int MOD = 1000000007; const int inf = 2000000000; const int mod = 1007050321; const double e = 0.000001; const int N = 200005; const bool aut = 788480; con...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<long long> t(n), x(n); for (int i = 0; i < n; i++) { cin >> t[i] >> x[i];...
module opicorv32_memif_wrap ( mem_do_wdata, mem_do_rdata, mem_do_prefetch, mem_wordsize, mem_rdata, mem_do_rinst, mem_ready, next_pc, reg_op2, reg_op1, resetn, clk, mem_done, mem_valid, mem_instr, mem_addr, mem_wdata, mem_wstrb, mem_rdata_latch...
#include <bits/stdc++.h> template <typename T> inline void read(T &x) { x = 0; register char ch; register bool fl = 0; while (ch = getchar(), ch < 48 || 57 < ch) fl ^= ch == - ; x = (ch & 15); while (ch = getchar(), 47 < ch && ch < 58) x = (x << 1) + (x << 3) + (ch & 15); if (fl) ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 02/12/2015 03:26:51 PM // Design Name: // Module Name: // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision: ...
#include <bits/stdc++.h> template <typename T> void rd(T& x) { long long f = 0, c; while ((c = getchar()) < 48 || 57 < c) f ^= !(c ^ 45); x = (c & 15); while (47 < (c = getchar()) && c < 58) x = x * 10 + (c & 15); if (f) x = -x; } template <typename T> inline void pt(T x) { if (x < 0) ...
#include <bits/stdc++.h> int ex[] = {1, -1, 0, 0}; int wye[] = {0, 0, 1, -1}; using namespace std; vector<int> vt[10005]; bool visit[10005]; int n, x, y, an; void dfs(int node) { if (visit[node]) return; visit[node] = true; int siz = vt[node].size(); int tmp; for (int i = 0; i < siz; i...
#include <bits/stdc++.h> using namespace std; int n; pair<int, int> arr[100000 + 5]; int main() { cin >> n; int L = 0, R = 0; for (int i = 1; i <= n; i++) { cin >> arr[i].first >> arr[i].second; L += arr[i].first; R += arr[i].second; } int ans = abs(L - R); int id = 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 law...
#include <bits/stdc++.h> using namespace std; int n, k, num[100001], mxn, contador; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> num[i]; } if (n == 1) { cout << 1; return 0; } for (int i = 2; i < n; i++) { if (num[i] == num[i - 1] + num[i - 2]) ...
#include <bits/stdc++.h> using namespace std; map<long long, int> mp; int n; int main() { scanf( %d , &n); int t; long long s = 0; for (int i = 1; i <= n; i++) { scanf( %d , &t); s += t; mp[s]++; } int ans = 0; map<long long, int>::iterator it; for (it = mp.begi...
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-5; bool board[8][8]; const int dx[8] = {1, 2, 2, 1, -1, -2, -2, -1}; const int dy[8] = {2, 1, -1, -2, -2, -1, 1, 2}; void check(int x, int y, int n) { board[x][y] = true; if (n == 1) { for (int i = (0); i < (int)(8); ++...
/* * Copyright 2020-2022 F4PGA 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agr...
`timescale 1 ps / 1 ps module daala_zynq_wrapper (DDR_addr, DDR_ba, DDR_cas_n, DDR_ck_n, DDR_ck_p, DDR_cke, DDR_cs_n, DDR_dm, DDR_dq, DDR_dqs_n, DDR_dqs_p, DDR_odt, DDR_ras_n, DDR_reset_n, DDR_we_n, FIXED_IO_ddr_vrn, FIXED_IO_ddr_vrp, FIXED_IO_mio,...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2017/11/29 22:40:09 // Design Name: // Module Name: top // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision: // Revisio...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 11:27:42 05/05/2015 // Design Name: // Module Name: key_Processor // Project Name: // Target Devices: // Tool versions: // Description: // // D...
//Legal Notice: (C)2016 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 //simulation files), and any associate...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, flag = 0; cin >> n >> m; char c; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> c; if (c == B || c == W || c == G ) continue; else flag = 1; } } ...
/* Copyright (c) 2014-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...
module fifo # (parameter abits = 400, dbits = 1)( input reset, clock, input rd, wr, input [dbits-1:0] din, output [dbits-1:0] dout, output empty, output full, output reg ledres ); wire db_wr; wire db_rd; reg dffw1, dffr1; reg [dbits-1:0] out; initial ledres = 0; reg [1:0] count; re...