text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; struct in { int x, y; } a[300000]; int get(int prex, int prey, int x, int y, int k) { int num, ans = 100000000; if (prex <= k) { num = (prex + x + k - 1) / k - 1; if (y == num) ans = prex + x - num * k; else if (y > num && y <= ...
#include <bits/stdc++.h> using namespace std; const int N = 1000005; const int inf = 1e9 + 7; long long fac[N], M, inv[N]; inline long long po(long long x, long long y, long long z) { long long res = 1; while (y) { if (y & 1) res = res * x % z; x = x * x % z; y >>= 1; } retur...
#include <bits/stdc++.h> #define pb push_back #define pf push_front #define fi first #define se second using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0); ll t, n, k; cin >> t; while(t--) { cin >> n >> k; for(ll i=1;...
// Accellera Standard V2.3 Open Verification Library (OVL). // Accellera Copyright (c) 2005-2008. All rights reserved. `ifdef OVL_ASSERT_ON wire xzcheck_enable; `ifdef OVL_XCHECK_OFF assign xzcheck_enable = 1'b0; `else `ifdef OVL_IMPLICIT_XCHECK_OFF assign xzcheck_enable = 1'b0; `else assign xzcheck_...
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int x; x = n % 4; if (n == 0) cout << 1 ; else if (x == 0) cout << 6 ; else if (x == 1) cout << 8 ; else if (x == 2) cout << 4 ; else if (x == 3) 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 law...
#include <bits/stdc++.h> using namespace std; bool Notlucky(int x) { for (int i = x; i != 0; i /= 10) { if (i % 10 == 8 || i % 10 == -8) return false; } return true; } int main() { int a, b; cin >> a; b = a + 1; while (Notlucky(b)) { b++; } cout << b - a; retu...
#include <bits/stdc++.h> using namespace std; const int32_t INFint = 1e9; const long long INFll = 1e18; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long t; cin >> t; while (t--) { long long n; cin >> n; long long arr[n]; for ...
/** * 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() { long long n, a, b, x, y, x1, y1; cin >> n >> a >> b; if (max(n - a, n - b) < max(a - 1, b - 1)) cout << black n ; else cout << white n ; return 0; }
module register #(parameter SIZE = 16, parameter DEF = {SIZE{1'bx}}) (input clk, input [SIZE-1:0] i, output reg [SIZE-1:0] o, input [1:0] rw); initial o <= DEF; always @(clk) begin case (rw) 2'b01 : begin o[SIZE/2-1 : 0] <= i[SIZE/2-1 : 0]; end 2'b10 : begin o[SIZE-1 : SIZE/2] <= i[SIZE-1 : SIZE/...
#include <bits/stdc++.h> using namespace std; void runTest() { long long int n, a, b, k; cin >> n >> a >> b >> k; long long int ans = 0; vector<long long int> v; for (long long int i = 0; i < n; i++) { long long int val; cin >> val; long long int temp = ((val % (a + b...
#include <bits/stdc++.h> using namespace std; void solve(int cnum) { int di[] = {-1, 0, 0, 1}; int dj[] = {0, -1, 1, 0}; int n, m; cin >> n >> m; vector<vector<int>> arr(n, vector<int>(m)); vector<vector<int>> ans(n, vector<int>(m)); for (int i = 0; i < n; ++i) for (int 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...
/** * 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 = 1000000007; struct M { int v[2][2]; } A, V, c[1 << 20]; struct Vec { int v[2]; } a[1 << 20], Vec0; bool E(const M& a) { return a.v[0][0] == 1 && a.v[1][1] == 1 && a.v[0][1] == 0 && a.v[1][0] == 0; } M operator*(const M& a, const...
// DESCRIPTION: Verilator: Test symbol table scope map and general public // signal reflection // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2015 by Todd Strader. module t ( input wire CLK ); foo #(.WIDTH (1)) foo1 (.*); foo #(.WIDTH (7)) foo7 (.*); foo #(.W...
/* * 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 v[200100], cnt[200020]; int n, s; int main(void) { ios::sync_with_stdio(false); cin >> n >> s; --s; int er = 0; int ans = 0; for (int(i) = (0); (i) < (n); ++(i)) { cin >> v[i]; cnt[v[i]]++; } if (v[s] != 0) { ans...
#include <bits/stdc++.h> using namespace std; ; clock_t start; mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); const long long N = 501, lmx = 11; long long mx[N][N][lmx][lmx], n, m, q, col[4][N][N], logg[N]; long long sum(long long k, long long r1, long long c1, long long r2, ...
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 10; const long long M = 1e9 + 7; int n, x, y, z; int last[N], to[2 * N], w[2 * N], num, nxt[2 * N]; long long a[N]; long long ans; void Add(int u, int v, int c) { nxt[++num] = last[u]; to[num] = v; w[num] = c; last[u...
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; struct node { int t; int x; int y; } tt[maxn]; int main() { int n, m, s, f; while (~scanf( %d%d%d%d , &n, &m, &s, &f)) { memset(tt, 0, sizeof tt); for (int i = 0; i < m; i++) { scanf( %d%d%d , &...
/* `BF.v' Balsa Verilog netlist file Created: Thu Apr 22 18:40:25 BST 2010 By: dell@dell-laptop (Linux) With net-verilog (balsa-netlist) version: 3.5.1 Using technology: example/four_b_rb Command line : (balsa-netlist -v BF.breeze) */ module AND3 ( out, in0, in1, in2 ); output out...
/** * 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 read() { int nm = 0, fh = 1; char cw = getchar(); for (; !isdigit(cw); cw = getchar()) if (cw == - ) fh = -fh; for (; isdigit(cw); cw = getchar()) nm = nm * 10 + (cw - 0 ); return nm * fh; } struct node { int x, y, w; } p[100001...
//------------------------------------------------------------------------------ // The confidential and proprietary information contained in this file may // only be used by a person authorised under and to the extent permitted // by a subsisting licensing agreement from ARM Limited. // // (C) COPYRIGHT 201...
#include <bits/stdc++.h> using namespace std; int l[100100]; int d[100100]; map<int, vector<int> > p; int cntd[202] = {0}; int main(int argc, char** argv) { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) cin >> l[i]; for (int i = 0; i < n; i++) cin ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int t; cin >> t; while (t--) { long long p, f, s, w, cntS, cntW; cin >> p >> f >> cntS >> cntW >> s >> w; if (s > w) { swap(cntS, cntW);...
/** * 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 long long int MOD = (long long int)1e9 + 7; long long int powmod(long long int a, long long int b) { long long int res = 1; while (b > 0) { if (b & 1) res = (res * a) % MOD; a = (a * a) % MOD; b = b >> 1; } return res % MOD; }...
/* 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; int d[1000001] = {0}; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0, a, b; i < m; ++i) scanf( %d%d , &a, &b), d[a]++, d[b]++; long long ans = 0; for (int i = 1; i <= n; ++i) { long long de = d[i], ade = n - 1 - de; ans +=...
//############################################################################# //# Purpose: SPI master Registers # //############################################################################# //# Author: Andreas Olofsson # ...
#include <bits/stdc++.h> using namespace std; void solve() { map<string, pair<string, long long>> best; long long n; cin >> n; for (long long i = 0; i < n; i++) { string name; long long score; cin >> name >> score; best[name].second = max(best[name].second, score); } ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int mod(int x, int m) { if (x < 0) x += m; return x % m; } int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> v(n); int m...
// megafunction wizard: %FIFO%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: small_fifo_test_72.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ====================...
module rs232 ( input clk, input resetn, input [ 3:0] ctrl_wr, input ctrl_rd, input [15:0] ctrl_addr, input [31:0] ctrl_wdat, output reg [31:0] ctrl_rdat, output reg ctrl_done, input rxd, output reg txd ); parameter integer BAUD_RATE = 115200; parameter integer CLOCK_FREQ_HZ = 50000000; localparam...
// ============================================================================= // COPYRIGHT NOTICE // Copyright 2006 (c) Lattice Semiconductor Corporation // ALL RIGHTS RESERVED // This confidential and proprietary software may be used only as authorised by // a licensing agreement from Latt...
/** * 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 N, T; void solve() { cin >> N; vector<long long int> cnt(N + 1); long long int x; for (long long int i = 0; i < N; i++) { cin >> x; cnt[x]++; } long long int ans = 0; for (long long int s = 2; s <= 2 * N; s++) { ...
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 7, N = 17, M = 16389, O = 131; int qp(int a, int b) { int r = 1; for (; b; b >>= 1, a = a * 1ll * a % P) if (b & 1) r = r * 1ll * a % P; return r; } int a[N], e[N][N], p[M], n, ll[O][O], lr[O][O], rl[O][O], rr[O][O]; int g(i...
#include <bits/stdc++.h> int main() { int n, m, min, max; scanf( %d %d %d %d , &n, &m, &min, &max); int arr[m]; for (int i = 0; i < m; i++) { scanf( %d , &arr[i]); } int chmin = 0, chmax = 0, wrong = 0; for (int i = 0; i < m; i++) { if (arr[i] == min) chmin = 1; if (arr[i...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:200000000 ) using namespace std; template <typename T> inline T Abs(T x) { return (x >= 0) ? x : -x; } template <typename T> inline T sqr(T x) { return x * x; } template <typename T> inline string toStr(T x) { stringstream st; ...
// test_usb_ft232.v `timescale 1 ns / 1 ps module test_usb32; reg clk = 0; reg reset = 1; // FT232 interface reg usb_clk = 0; wire wr_n; wire rd_n; wire oe_n; wire [7:0]data; reg txe_n = 1; reg rxf_n = 1; wire siwu_n; // avs_ctrl reg avs_ctrl_address = 1'bx; reg avs_ctrl_write = 0; reg [7:0]avs_...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; const int M1 = 1000000007; const int M2 = 1000000087; int N; int H1[310000]; int P1[310000]; int H2[310000]; int P2[310000]; int HH1, HH2; int n, m; vector<int> g[100007]; string s[100007]; char t[300007...
#include <bits/stdc++.h> using namespace std; #define int long long //#define int unsigned int //#define pb push_back //#define mp make_pair #define mod 1000000007 #define double long double #define all(x) x.begin(), x.end() #define debug(x) cout << #x << = << x << n const int inf=1e18; ...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 400; int n, m, wynik, A[N], B[N]; map<double, bitset<120> > mapa; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> A[i]; for (int i = 1; i <= m; i++) cin >> B[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 n; long long b[500010], a[500010]; void solve() { cin >> n; for (int i = 0; i < n; i++) cin >> b[i]; long long sum = 0, flag = 1; for (int i = 0; i < n; i++) sum += b[i]; if (sum % (n * (n + 1) / 2)) flag = 0; sum /= n * (n + 1) / 2...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 1; int n, m; vector<int> A[MAXN]; int d[MAXN]; void dfs(int nod) { for (int i = 0; i < A[nod].size(); i++) { int v = A[nod][i]; if (d[v] == 0) { d[v] = d[nod] + 1; dfs(v); } } } int main() { ...
/** * 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...
/** * 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 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Sat May 27 21:26:04 2017 // Host : GILAMONSTER running 64-bit major release (...
/*============================================================================ 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...
/* ****************************************************************************** * File Name : tb_ada_exu.v * Project : ADA processor * Version : 0.1 * Date : Aug 17th, 2014 * Author : Angel Terrones <> * * Disclaimer : Copyright © 2014 Angel Terrones * ...
#include <bits/stdc++.h> using namespace std; const int maxn = 4e6 + 7; const int inf = INT_MAX; const long long inff = 1e18; const long long mod = 1e9 + 7; int d, s; pair<int, int> dp[maxn]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cin >> d >> s; for (int i = 0; i <= (d + 1...
#include <bits/stdc++.h> using namespace std; int n, a[2006]; int one, g, mn = 1e9; int gcd(int _a, int _b) { return _b == 0 ? _a : gcd(_b, _a % _b); } int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); g = gcd(g, a[i]); if (a[i] == 1) one++; } i...
(************************************************************************) (* * The Coq Proof Assistant / The Coq Development Team *) (* v * Copyright INRIA, CNRS and contributors *) (* <O___,, * (see version control and CREDITS file for authors & dates) *) (* \VV/ *********...
#include <bits/stdc++.h> using namespace std; int b1[] = {0, 0, 1, -1}; int b2[] = {1, -1, 0, 0}; int d1[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int d2[] = {-1, 0, 1, -1, 1, -1, 0, 1}; string st; const int mxn = 1e6; struct tp { int tt, cl, op; } tree[4 * mxn]; void build_tree(int s, int e, int index) ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:51:52 04/07/2015 // Design Name: // Module Name: top // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Rev...
#include <bits/stdc++.h> using namespace std; const int N = 500010; int ans[N], arr[N], MAX[N]; long long power_mod(long long x, long long y) { x %= 1000000007; long long res = 1; while (y) { if (y & 1) { res = (res * x) % 1000000007; } y /= 2; x = (x * x) % 100000000...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool getmin(T *a, const T &b) { if (b < *a) { *a = b; return true; } return false; } template <class T> inline bool getmax(T *a, const T &b) { if (b > *a) { *a = b; return true; } return f...
`timescale 1ns / 1ps /* * Simple Brainfuck CPU in Verilog. * Copyright (C) 2011 Sergey Gridasov <> * * 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 3 of the License, or ...
#include <bits/stdc++.h> using namespace std; int st[610], aim[(300010)], nxt[(300010)], ln; int flow[(300010)], con[(300010)], cost[(300010)]; int inq[610], dis[610]; int g[610], e[610]; int q[610]; int a[610]; int d[610 << 3], tag[610 << 3], dn; int num[610]; int N, source, remit; int ans; int...
#include <bits/stdc++.h> int main() { int n, m, i, j, s; char a[12][11]; scanf( %d%d , &n, &m); for (i = 0; i < n; i++) scanf( %s , a[i]); s = 0; for (i = 0; i < n; i++) for (j = 0; j < m; j++) if (a[i][j] == W ) { if (a[i - 1][j] == P ) { s++; ...
#include <bits/stdc++.h> using namespace std; template <typename num_t> inline void addmod(num_t& a, const long long& b, const int& m) { a = (a + b) % m; if (a < 0) a += m; } template <typename num_t> inline void update_max(num_t& a, const num_t& b) { a = max(a, b); } template <typename num_...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: pcx_buf_p4.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/or...
#include <bits/stdc++.h> using namespace std; int n, x; int cnt[100], b[105][105], sol[105][105], c[105][105], a[105][105]; inline void Mult_Mat(int a[][105], int b[][105]) { int i, j, k, s; for (i = 0; i < x; ++i) for (j = 0; j < x; ++j) { s = 0; for (k = 0; k < x; ++k) ...
#include <bits/stdc++.h> const int N = 1000001; using namespace std; char sub[N], s[N], l[N]; int a[10]; int main() { scanf( %s , s); int i, j, len1, len2; len1 = strlen(s); for (i = 0; i < len1; i++) a[s[i] - 0 ]++; scanf( %s , sub); len2 = strlen(sub); for (i = 0; i < len2; i++)...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: cpx_buf_p0_even.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 a...
#include <bits/stdc++.h> using namespace std; long long n; vector<long long> G[500005]; long long t1, d1, t2, d2; long long dis1[500005], dis2[500005]; long long inp[500005], in[500005]; stringstream ss; void dfs1(long long u, long long fa, long long d) { if (d > d1) { d1 = d; t1 = u; ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); int q; cin >> q; while (q--) { string s; cin >> s; vector<char> v[2]; for (int i = 0; i < s.size(); i++) v[s[i] % 2].push_back(s[i]); int p1, p2; ...
#include <bits/stdc++.h> using namespace std; int dx[] = {1, 0, -1, 0, -1, 1, -1, 1}; int dy[] = {0, 1, 0, -1, -1, 1, 1, -1}; const double eps = 1e-6; const int N = 1e9; void moha() {} bool vis[1505][1505]; int comp[1505][1505][2]; char x[1505][1505]; int n, m; int row(int x) { return (x + n * 150...
/** * 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 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Sun Jan 22 23:53:58 2017 // Host : TheMosass-PC running 64-bit major release ...
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, bool> fuck; int n, m; char s[5]; int x, y; long long ans; int dx, dy; int main() { scanf( %d%d , &n, &m); scanf( %d%d , &x, &y); scanf( %s , s + 1); if (s[1] == U ) dx = -1; else dx = 1; if (s[2] == L...
module main; reg [7:0] a; reg [2:0] adr, w_adr; reg rst, clk, ae, wr; (* ivl_synthesis_on *) always @(posedge clk) if (rst) begin a <= 8'b00000000; adr <= 3'b000; end else if (ae) begin adr <= w_adr; end else if (wr) begin adr <= adr + 1; a[adr] <= 1; end (* ivl_synt...
module tvout ( input pixel_clk, input rst, output reg [8:0] cntHS, output reg [8:0] cntVS, output wire vbl, output wire hsync, output wire out_sync ); wire screen_sync = (cntHS < 37) ? 1'b0 : 1'b1; wire in_vbl = ((cntVS >= 5) & (cntVS < 309)) ? 1'b0 : 1'b1; reg vbl_sync; reg interlace; al...
#include <bits/stdc++.h> using namespace std; string str; bool judge(char c) { return (c == _ || islower(c) || isdigit(c) || isupper(c)); } int main() { int cnt = 0, count = 0, type = 0, len; cin >> str; type = 0; len = str.length(); for (int i = 0; i < len; i++) { char c = str...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int down[N], sz[N], up[N], n; vector<pair<int, bool> > adj[N]; void dfs(int s, int p) { sz[s] = 1; for (auto it : adj[s]) { if (it.first != p) { dfs(it.first, s); sz[s] += sz[it.first]; if (it.second) ...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2014 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Version : Ver...
#include <bits/stdc++.h> const int N = 2000010; using namespace std; char s[N], t[N]; int main() { int n; scanf( %d , &n); scanf( %s%s , s, t); int a[5] = {}; for (int i = 0; i < 2 * n; i++) { a[((s[i] == 1 ) << 1) | (t[i] == 1 )]++; } int s0 = 0, s1 = 0; int t = 0; w...
#include <bits/stdc++.h> using namespace std; int s, t, n; string str; bool flag = true, flag1 = true; int main() { scanf( %d , &n); cin >> str; for (int i = 0; i < n; i++) { if (str[i] == R && flag) { s = i; flag = false; } if (str[i] == L && flag1) { ...
// Copyright 1986-2014 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2014.1 (lin64) Build 881834 Fri Apr 4 14:00:25 MDT 2014 // Date : Tue May 13 22:55:34 2014 // Host : macbook running 64-bit Arch Linux // ...
#include <bits/stdc++.h> using namespace std; const int maxn = 105; int n; int a[maxn]; int p; double dp[maxn][maxn]; double release(int x) { double res = 1; for (register double i = x + 1; i <= n; i++) { res *= (i - x); res /= i; } return res; } signed main() { scanf( ...
#include <bits/stdc++.h> using namespace std; const int Nmax = 1e6 + 7; int n; string s; int dp[Nmax]; vector<int> v; int ans, ans1, ans2; inline int get(string s) { int cnt = 0; int mx = 4 * n; ans = 0; for (int i = 0; i < n; i++) { if (s[i] == ) ) cnt--; else ...
/** * 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...
#include <bits/stdc++.h> #define inf 0x3f3f3f3f #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #define rep(i, a, n) for(int i = a; i <= n; ++ i) #define per(i, a, n) for(int i = n; i >= a; -- i) //#define ONLINE_JUDGE using namespace std; typedef long long ll; const int mod=1e9+7; template<type...
#include <bits/stdc++.h> using namespace std; int n, a[100010], mx1 = -100010, mx2 = -100010 - 10, ans = 1, cnt[100010]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { if (a[i] > mx1) { mx2 = mx1; mx1 = a[i]; cnt[a[i]]--; ...
#include <bits/stdc++.h> using namespace std; int n, m; char a[55][55]; int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1}; vector<pair<int, int> > G[2555]; int vis[2555]; int bfs(int i, int j) { memset(vis, -1, sizeof vis); deque<pair<int, int> > q; q.push_front(make_pair(i * m + j, 0)); in...
#include <bits/stdc++.h> using namespace std; const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230; template <class T> int getbit(T s, int i) { return (s >> 1) & 1; } template <class T> T onbit(T s, int i) { return s | (T(1) << i); } template <class ...
#include <bits/stdc++.h> using namespace std; int par[100005], val[100005]; int lefm[100005], rim[100005]; int root = 0; vector<vector<int> > adjl; int n; void pre(int node) { if (adjl[node].size() == 0) { lefm[node] = val[node]; rim[node] = val[node]; return; } for (int 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; const int N = 3e5 + 5; const int M = 205; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; struct node { int l, r, id; } p[N << 1]; bool cmp(node a, node b) { return a.r < b.r; } int sum[N << 4]; void update(int p, int L, int R, int pos) { if...
#include <bits/stdc++.h> using namespace std; bool dp[5001][5001]; vector<int> bits[10001]; vector<pair<int, int> > cur; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s, ans; cin >> s; int n = s.size(); dp[0][0] = 1; cur.push_back(make_pair(0, 0)); int cn...
//############################################################################# //# Function: Carry Save Adder (9:2) # //############################################################################# //# Author: Andreas Olofsson # ...
// // Generated by Bluespec Compiler, version 2013.01.beta5 (build 30325, 2013-01-23) // // On Mon Feb 3 15:05:32 EST 2014 // // // Ports: // Name I/O size props // RDY_s_request_put O 1 // s_response_get O 153 // RDY_s_response_get O 1 // RDY...
#include <bits/stdc++.h> using namespace std; long long* parent; long long* size; void make_set(long long v) { parent[v] = v; size[v] = 1; } long long find_set(long long v) { if (v == parent[v]) return v; return parent[v] = find_set(parent[v]); } void union_set(long long u, long long v) ...