text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; template <typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>; struct RangeIncrement { vector<long long> tree, lazy; RangeIncrement(int n) : tree(n << 2), lazy(n << 2) {} void refresh(int i, int l, int r) { if (lazy[i] != 0) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int *a = new int[m]; if (m % 2 == 0) { for (int i = 0; i < m; i++) { if (i % 2 == 0) a[i] = m / 2 - i / 2; if (i % 2 == 1) a[i] = m / 2 + 1 + (i - 1) / 2; } } else { for (int i =...
#include <bits/stdc++.h> void rd(int &x) { x = 0; int f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch <= 9 && ch >= 0 ) x = x * 10 + ch - 0 , ch = getchar(); x *= f; } void lrd(long long &x) { x = 0; ...
`timescale 1ns / 1ps `default_nettype none ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:24:57 12/06/2015 // Design Name: // Module Name: control_rasterint // Project Name: // Target Devices: // Tool versions: // Descrip...
module autoinst_name_bug245 ( ); /*AUTOINPUT*/ /*AUTOOUTPUT*/ /*AUTOWIRE*/ wire [3:0] f4_dotnamed; /*Sub AUTO_TEMPLATE ( .dtmp_NO (d_NO), .etmp_dotnamed (etmp_dotnamed), );*/ Sub sub ( .bign1_dotnamed, // Outputs .bign2_dotnamed, /*AUTOINST*/); endmodule mo...
`include "bsg_defines.v" module bsg_nonsynth_chipset_rocket #(parameter num_channels_p=4 , parameter channel_width_p=8 , parameter master_bypass_test_p=5'b11111 // localparams , parameter htif_destid_p = 0 , parameter nasti_destid_p = 1 , parameter nodes_lp = 3 , paramete...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: spu_lsurpt1.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/o...
// 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 : Thu May 25 21:06:44 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> const int INF = (int)1e9 + 7; int f(const std::vector<int> &arr, int k, int d) { std::list<std::pair<int, int>> events, se; for (auto &it : arr) { events.push_back({it - d, 0}); se.push_back({it + d, 1}); } events.merge(se); int bal = 0; for (auto it : ev...
////////////////////////////////////////////////////////////////////// //// //// //// Main datapath for HIGHT Crypto Core //// //// //// //// This file is part of the HIGHT...
module rx #( parameter STATE_IDLE = 3'h0, parameter STATE_PREAMBLE = 3'h1, parameter STATE_DATA = 3'h2, parameter STATE_OK = 3'h3, parameter STATE_DROP = 3'h4, parameter STATE_ERROR = 3'h5 )( input ...
/* * Copyright (c) 2001 Juergen Urban * * 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; int vis[7], sum[7]; string a[7], t[7]; vector<string> ans(10, { ), now; void solve() { now.clear(); for (int i = 1; i <= 6; i++) sum[i] = (int)t[i].size(); if (sum[2] <= sum[1] || sum[2] <= sum[3] || sum[5] <= sum[4] || sum[5] <= sum[6]) ...
// *************************************************************************** // *************************************************************************** // Copyright 2011-2015(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, /...
#include <bits/stdc++.h> using namespace std; const long long maxn = 2e5 + 5; struct Node { long long ls, rs, val, key, cnt, tag, add; }; Node t[maxn]; long long pol; void newnode(long long vv) { t[++pol].val = vv; t[pol].cnt = 0; t[pol].key = rand(); t[pol].ls = t[pol].rs = 0; t[p...
#include <bits/stdc++.h> int power_ten(int n) { int digits = 0; while (n >= 10) { n = n / 10; digits = digits + 1; } n = 1; while (digits > 0) { n = n * 10; digits = digits - 1; } return n; } int next_number(int sum, int count) { if (count == 1) { retu...
#include <bits/stdc++.h> double A[200000], B[200000], C[200000], p[200000], F[200000]; int i, j, n, m; int main() { scanf( %d , &n); double now, last = 0; C[0] = 1; for (i = 1; i <= n; i++) { if (i <= n) scanf( %lf , &now); C[i] = now * (C[i - 1]) + 1 - now; B[i] = now * (B[i - 1...
/** * 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 = 1e9; int n, m; char mt[1505][1505]; const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}; bool flag = false; pair<int, int> vis[1505][1505]; void dfs(int x, int y) { int ax = (x % n + n) % n, ay = (y % m + m) % ...
module alu(A, B, OP, Y, C, V, N, Z, HEX7, HEX6, HEX5, HEX4, HEX3, HEX2, HEX1, HEX0); input [7:0] A; input [7:0] B; input [2:0] OP; output [7:0] Y; output C; output V; output N; output Z; output [6:0] HEX7; output [6:0] HEX6; output [6:0] HEX5; output [6:0] ...
#include <bits/stdc++.h> using namespace std; struct edge { int v, nxt; } e[200005 << 1]; int top = 1; int head[200005]; void Add_Edge(int u, int v) { e[++top] = edge{v, head[u]}; head[u] = top; } int n; int a[200005], par[200005][21], dep[200005], size[200005]; void dfs(int u, int fa) {...
#include <bits/stdc++.h> using namespace std; int n; int a[26]; int b[26]; bool ok; inline void go(int v, int rem, int cur, int last) { if (v == n) { ok = 1; for (int i = 1; i <= n && ok; ++i) if (b[i]) ok = 0; if (ok) { puts( YES ); exit(0); } } i...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; bool isSquare(int r) { return int(sqrt((double)r)) * int(sqrt((double)r)) == r; } bool check(int a, int b, int c, int d, int N, int M) { int ans = 0; ans += isSquare(a * a * (M - 1) + b * b); ans += isSqua...
// // 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) // ...
// module ddr2_ex_lfsr8 ( clk, reset_n, enable, pause, load, data, ldata); parameter seed = 32; input clk; input reset_n; input enable; input pause; input load; output[8 - 1:0] data; wire[8 - 1:0] data; input[8 - 1:0] ldata; reg[8 - 1:0] lfsr_data; assign data = lfsr_data ; alwa...
#include <bits/stdc++.h> using namespace std; int xd[] = {0, 1, 0, -1}; int yd[] = {1, 0, -1, 0}; int xx[] = {0, 1, 0, -1, 1, -1, 1, -1}; int yy[] = {1, 0, -1, 0, 1, 1, -1, -1}; int kx[] = {-2, -1, -2, -1, 1, 2, 2, 1}; int ky[] = {1, 2, -1, -2, -2, -1, 1, 2}; bool islucky(int x) { int four = 0, seve...
/** * 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...
/** * Used by the SD card reader to get responses from the * SPI flash interface. * * @author Robert Fotino, 2016 */ module spi_receiver ( input clk, input sclk_posedge, input sclk_negedge, input reset, input ...
// synopsys translate_off `include "rtl/verilog/or1200/timescale.v" // synopsys translate_on `include "rtl/verilog/or1200/or1200_defines.v" //************************************************************// // - a lot work in progress, many thing are useless // TODO: clean this up and make it more general // TODO: add ...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7, MAXN = 1e5 + 10; int n, l, r, a[MAXN], b[MAXN]; vector<int> aa, bb; int main() { ios_base::sync_with_stdio(0); cin >> n >> l >> r; for (int i = 1; i <= n; ++i) { cin >> a[i]; if (l <= i && i <= r) aa.push_back(a[i])...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; struct line { int sx, sy, ex, ey; friend bool operator<(const line &A, const line &B) { return A.sx < B.sx; } }; map<char, line> mp; int n, m; char s[2005][2005], p[2005][2005], mxx; void init() { for (char x = a ; x <=...
#include <bits/stdc++.h> using namespace std; const int maxn = (int)1e5 + 10; bool isp[maxn]; int _prime[maxn], lp = 0; int _minCost[maxn]; void InitPrime() { isp[0] = isp[1] = true; for (int i = 4; i < maxn; i += 2) isp[i] = true; for (int i = 3; i * i < maxn; i += 2) if (!isp[i]) ...
#include <bits/stdc++.h> using namespace std; const int N = 500010; const int INF = 0x3f3f3f3f; const int iinf = 1 << 30; const long long linf = 2e18; const int MOD = 1000000007; const double eps = 1e-7; void print(int x) { cout << x << endl; exit(0); } void PRINT(string x) { cout << x <...
#include <bits/stdc++.h> using namespace std; vector<pair<int, pair<char, string>>> vec; int main() { unsigned long long int n, i, j, n1, cnt = 0; cin >> n; string s; char r; for (i = 1; i <= n; i++) { cin >> s; n1 = s.size(); cnt = 0; for (j = 0; j < n1; j++) { ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003-2007 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=1; // verilator lint_on GENCLK reg [31:0] long; reg [6...
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1000000000000; const double eps = (double)1e-8; const int mod = (int)1000000007; const int maxn = (int)1e6 + 5; int n, res, cnt, z[maxn]; pair<pair<int, int>, pair<int, int> > a[maxn]; vector<int> t[maxn]; vector<pair<int, ...
// *************************************************************************** // *************************************************************************** // Copyright 2013(c) Analog Devices, Inc. // Author: Lars-Peter Clausen <> // // All rights reserved. // // Redistribution and use in source and binary forms, ...
#include <bits/stdc++.h> using namespace std; using LL = long long; template <class T> int size(T &&x) { return int(x.size()); } template <class A, class B> ostream &operator<<(ostream &out, const pair<A, B> &p) { return out << ( << p.first << , << p.second << ) ; } template <class T> ...
/* * 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 N = 154321; int n, m, r, k, row[N], col[N]; long long ans = 0; struct node { int a, b; long long val; bool operator<(const node &rhs) const { return val < rhs.val; } }; priority_queue<node> pq; int main() { cin >> n >> m >> r >> k; ...
/** * 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...
#include <bits/stdc++.h> using namespace std; const int MOD = (int)7 + (int)1e9; const int N = 1000005; const double PI = 4 * atan(1); const double eps = 1e-10; const long long oo = 1e10; const int K = 26; struct query { int a, t, x; query() { a = -1, t = -1, x = -1; } query(int _a, int _t, ...
#include <bits/stdc++.h> using namespace std; void fileio() {} vector<vector<long long int>> g; long long int cube_root(long long int x) { long long int lo = 0, hi = 1e6 + 10; while (lo <= hi) { long long int m = (lo + hi) / 2; long long int val = m * m * m; if (val == x) return m; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int ans = -1; for (int i = 0; i < n - 1; i++) { if (s[i + 1] < s[i]) { ans = i; break; } } if (ans == -1) cout << NO ; else { cout << YES << endl; ...
/* File: fifo_full_block.v This file is part of the Parallella FPGA Reference Design. Copyright (C) 2013 Adapteva, Inc. Contributed by Roman Trogan <> 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 Soft...
#include <bits/stdc++.h> using namespace std; struct EDGE { int to, next, w; } e[400010]; int head[200010], top; void add(int u, int v, int w) { e[top].to = v; e[top].next = head[u]; e[top].w = w; head[u] = top++; } vector<int> vv; int vis[200010], tmpp = -1; long long in_max; in...
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; long long int memo[1005][2005][4]; int n, k; void solve() { for (int i = 2; i <= n; i++) { for (int j = 1; j <= i * 2; j++) { memo[i][j][0] = (memo[i - 1][j][0] + memo[i - 1][j][1] + memo[i - 1]...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false), cin.tie(NULL); long long tests = 1; cin >> tests; while (tests--) { long long n, k; cin >> n >> k; map<pair<long long, long long>, long long> timers; set<pair<long long, long long...
#include <bits/stdc++.h> using namespace std; const int MAX = 140000; int sx[MAX + 10], ex[MAX], sy[MAX + 10], ey[MAX]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d %d %d %d , &sx[i], &sy[i], &ex[i], &ey[i]); vector<pair<int, int> > px, py; for (int i = 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; const int NMax = 1003; enum directions { EAST, NORTH }; struct point { int x, y; }; point a[NMax]; int n; int test(int searchDir, point a[], long double x, long double y) { if (searchDir == NORTH) { int nr = 0; for (int i = 1; i <= n; ++i...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of inst_vb_e // // Generated // by: wig // on: Sat Mar 3 09:45:57 2007 // cmd: /cygdrive/c/Documents and Settings/wig/My Documents/work/MIX/mix_0.pl -nodelta ../../udc.xls // // !!! Do not edit this 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 la...
#include <bits/stdc++.h> using namespace std; struct SCC { int n; vector<int> comp, order; vector<bool> used; vector<vector<int> > G, RG; SCC(int _n = 0) : n(_n), comp(_n, -1), used(_n, false), G(_n), RG(_n) {} void add_edge(int from, int to) { G[from].push_back(to); RG[to].push_...
#include <bits/stdc++.h> #pragma comment(linker, /stack:256000000 ) #pragma gcc optimize( O3 ) #pragma gcc target( sse4 ) using namespace std; mt19937 rng(2391); mt19937 gnr(chrono::high_resolution_clock::now().time_since_epoch().count()); template <typename A> istream& operator>>(istream& fin, vector<...
// ------------------------------------------------------------- // // File Name: hdl_prj\hdlsrc\controllerPeripheralHdlAdi\controllerperipheralhdladi_pcore_axi_lite.v // Created: 2014-09-08 14:12:15 // // Generated by MATLAB 8.2 and HDL Coder 3.3 // // ------------------------------------------------------------- ...
#include <bits/stdc++.h> using namespace std; int dp[100010][3]; vector<int> v; int n; int solve(int i, int op, int last) { if (i == n) { return 0; } if (dp[i][op] != -1) { return dp[i][op]; } int ans = 0x3f3f3f3f; int aux = op; if (aux == 2) { aux = -1; } ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 13:21:18 03/06/2017 // Design Name: DNlatch_NAND // Module Name: D:/Projects/XilinxISE/HW1/Homework1/testDNlatch_NAND.v // Project Name: Homework1 // Target Device: ...
#include <bits/stdc++.h> const int maxn = 100005; int n, cnt; int a[maxn], p[maxn]; int main() { scanf( %d , &n); p[1] = 1; for (int i = 2; i <= n; i++) if (p[i] == 0) { p[i] = ++cnt; for (int j = i; j <= n; j += i) a[j] = cnt, p[j] = 1; } for (int i = 2; i <= n; 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 la...
#include <bits/stdc++.h> using namespace std; long long int modinverse(long long int x, long long int y) { if (y == 0) { return 1; } long long int p = modinverse(x, y / 2) % 1000000007; p = (p * p) % 1000000007; return (y % 2 == 0) ? p : (x * p) % 1000000007; } long long int modexp(lon...
`timescale 1ns / 1ps module KEYBOARD (ROW, KEY_BUFFER, PRESS_VALID, COLUMN, reset, circuit_clk, clk); input clk, circuit_clk; input reset; input [3:0] COLUMN; output [3:0] ROW; output [3:0] KEY_BUFFER; output PRESS_VALID; reg [3:0] ROW; reg [3:0] DEBOUNCE_COUNT; reg [3:0] SCAN...
/* * 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-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; long long Set(long long N, long long pos) { return N = N | (1 << pos); } long long reset(long long N, long long pos) { return N = N & ~(1 << pos); } bool check(long long N, long long pos) { return (bool)(N & (1 << pos)); } void CI(long long &_x) { scanf( %d , &_x)...
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } long long int modInverse(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 law...
`timescale 1ns / 1ps // @input // clk_src: clock source group // ALARM_STEP: HZ of alarm sparkle // power: power of washing machine // weight_ch: signal for changing weight // mode_ch: signal for changing mode // w_r_d_end: signal expliciting which phase has finished // @output // alarm: alarm led module ring #(parame...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); int ans = 0; while (n != 0) { ans++; string s = to_string(n); int maior = s[0] - 0 ; for (int i = 0; i < s.size(); i++) { maior = max(maior, s[i] - 0 ); } n -= maior; ...
#include <bits/stdc++.h> using namespace std; template <class T> inline void rd(T &x) { x = 0; char c = getchar(); int f = 1; while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) x = x * 10 - 0 + c, c = getchar(); x *= f; } const int N = 110...
#include <bits/stdc++.h> using namespace std; long long Rev[35], C[35][35]; long long powmod(long long x, long long y = 998244353 - 2, long long p = 998244353) { long long ans = 1; while (y) { if (y & 1) ans = ans * x % 998244353; x = x * x % 998244353; y >>= 1; } ...
/* * 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 maxn = 2e5 + 5; int n, k, a[maxn], ans[maxn], pos[maxn]; class Node { public: int l, r; }; Node lis[maxn]; int main() { scanf( %d%d , &n, &k); for (int(i) = 0; (i) < (n); (i)++) { cin >> a[i + 1]; pos[a[i + 1]] = i + ...
#include <bits/stdc++.h> #pragma GCC target( avx ) #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize( Ofast ) #pragma GCC optimize( inline ) #pragma GCC optimize( -fgcse ) #pragma GCC optimize( -fgcse-lm ) #pragma GCC optimize( -fipa-sra ) #pragma GCC optimize( -ftree-pre ) #pragm...
#include <bits/stdc++.h> using namespace std; class subtractions { private: int _a, _b; int _operations; bool even_divide(int& a, int& b) { if (b > a && !(b % a)) { _operations += (b / a); return true; } else if (a >= b && !(a % b)) { _operations += (a / b); ...
NET "vga_red<0>" LOC = P50 | IOSTANDARD = LVTTL; NET "vga_red<1>" LOC = P40 | IOSTANDARD = LVTTL; NET "vga_green<0>" LOC = P34 | IOSTANDARD = LVTTL; NET "vga_green<1>" LOC = P32 | IOSTANDARD = LVTTL; NET "vga_blue<0>" LOC = P29 | IOSTANDARD = LVTTL; NET "vga_blue<1>" LOC = P26 | IOSTANDARD = LVTTL; modu...
#include <bits/stdc++.h> using namespace std; struct data { int x, h, p; } a[100005]; int n, x[100005], kq[100005], st[4 * 100005]; void update(int id, int l, int r, int p, int v) { if (l > p || r < p) return; if (l == p && l == r) { st[id] = v; return; } int m = (l + r) >> 1; ...
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 1; const long long INF = 1e9 + 7; const long long inf = 1e18; vector<long long> adj[N]; long long vis[N]; long long ans[N]; long long ct; void dfs(long long node) { vis[node] = ct; ans[ct]++; for (auto it : adj[node]) ...
// (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...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
#include <bits/stdc++.h> using namespace std; int n; int m; void bfs(int u, vector<pair<int, int>> &p, vector<vector<pair<int, int>>> &adj) { queue<int> q; q.push(u); while (!q.empty()) { int cur = q.front(); q.pop(); for (auto as : adj[cur]) { int v = as.first; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; map<string, string> map1; for (int i = 0; i < n; ++i) { string t1, t2; cin >> t1 >> t2; map1[t2] = t1; } for (int j = 0; j < m; ++j) { string t1, t2, t3; cin >> t1 >> t2; f...
#include<bits/stdc++.h> typedef int LL; typedef double dl; #define opt operator #define pb push_back #define pii std::pair<LL,LL> const LL maxn=2e4+9,mod=998244353,inf=0x3f3f3f3f; LL Read(){ LL x(0),f(1); char c=getchar(); while(c< 0 || c> 9 ){ if(c== - ) f=-1; c=getchar(); } while(c>= 0 ...
#include <bits/stdc++.h> using namespace std; vector<int> g[5005]; int h[5005][5005], siz[5005]; int f[5005][5005], fa; int n, m, a[5005], b[5005], k; inline int min(const int x, const int y) { return x > y ? y : x; } void dfs(int x) { int to; siz[x] = 1; h[x][1] = b[x]; f[x][0] = 0, f[x][...
//----------------------------------------------------------------------------- // (c) Copyright 2012 - 2013 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 proper...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2005 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; reg [9:0] index; wire [7:0] index0 = index[7:0] + 8'h0; wire [7:0] index1 = index[7:0]...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const int ZERO = 2e5 + 5000; int n, w, h; struct node { int id, x, t; node() {} node(int _id, int _x, int _t) : id(_id), x(_x), t(_t) {} bool operator<(const node &a) const { return x < a.x; } } X[MAXN]; vector<node> Y...
// // Designed by Qiang Wu // 16K bytes, 32bit interface `timescale 1ns/1ps module lr_old(clk, raddr,waddr, data_in, data_out, we, reset); input clk; input [13:2] raddr; input [13:2] waddr; input [31:0] data_in; output [31:0] data_out; input [3:0] we; input reset; RAMB16_S4_2_altera localram0( /...
#include <bits/stdc++.h> using namespace std; const int MAX = 500000 + 24; int a[MAX]; int main() { int n, m, ans, tmp, u, v, fc; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &a[i]); } m = a[0]; ans = 0; for (int i = 0; i < n; i++) { while (i < n && a[i] == ...
#include <bits/stdc++.h> using namespace std; bool isPrime(int n) { if (n <= 1) { return false; } for (int i = 2; i < n; i++) { if (n % i == 0) { return false; } } return true; } vector<long long int> inisum; long long int binary(long long int target) { long l...
#include <bits/stdc++.h> using namespace std; int N, M, T; char str[1005]; int main() { int i, j, k; scanf( %d , &N); scanf( %s , str); for (i = 0; i < N; i++) if (str[i] == H ) M++; int Mc = 1005; k = 0; for (i = 0; i < M; i++) if (str[i] != H ) k++; int st = 0; ...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, neg = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) neg = -1; c = getchar(); } while (isdigit(c)) x = x * 10 + c - 0 , c = getchar(); return x * neg; } inline int qpow(int x, int e, int...
// (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...
/*****************************************************************************\ * * interface to IS61WV6416BLL-10TLI 64kx16 bit SRAM * * instantiation side: 128kx8 bit * * the clk input is MUST NOT be faster than 100 MHz * the inputs may be reset after 1 cycle * * transition chains: * read * done * r...
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0; cin >> n; for (int i = 0; i < n; i++) { int x, y, z; cin >> x >> y >> z; ans += (x + y + z >= 2); } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; static const int INF = 500000000; template <class T> void debug(T a, T b) { for (; a != b; ++a) cerr << *a << ; cerr << endl; } template <class T> void chmin(T& a, const T& b) { if (a > b) a = b; } template <class T> void chmax(T& a, const...
#include <bits/stdc++.h> using namespace std; void fre() { freopen( c://test//input.in , r , stdin); freopen( c://test//output.out , w , stdout); } template <class T1, class T2> inline void gmax(T1 &a, T2 b) { if (b > a) a = b; } template <class T1, class T2> inline void gmin(T1 &a, T2 b) ...
#include <bits/stdc++.h> using namespace std; int main() { long long k, a, b; cin >> k >> a >> b; if (k == 1) { cout << a + b << endl; return 0; } long long ret = (a / k) + (b / k); long long la = a % k, lb = b % k; if ((la / (k - 1) + (la % (k - 1) > 0)) <= b / k && ...
/* * Copyright (c) 2013, Quan Nguyen * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditi...