text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const long long maxN = 1e6 + 100; const long long maxM = 1e3 + 100; const long long mod = 1e9 + 7; const long long hmod = 1e16 + 7; const long double PI = 3.141592653; const long double eps = 1e-8; const long long D = 1379; const long long INF = 1e18 + 20;...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...
(************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *) (* \VV/ **************************************************************) (* // * Th...
// $Id: c_arbiter.v 5188 2012-08-30 00:31:31Z dub $ /* Copyright (c) 2007-2012, Trustees of The Leland Stanford Junior University 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...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const long long SIZE = 1e5 + 5; const long long mod = 1e9 + 7; int main() { long long t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0; string s, s1, s2; scanf( %lld , &q); while (q--) { cin >> s; ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int q; cin >> q; while (q--) { int n; cin >> n; string s, t; cin >> s >> t; string ss = s; string tt = t; sort(ss.begin(), ss.end()); sort(tt.beg...
/** * 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 tests; scanf( %d , &tests); while (tests--) { int item; cin >> item; vector<int> v; set<int> s; int temp; for (int i = 0; i < item; i++) { scanf( %d , &temp); v.push_back(temp); s.i...
`timescale 1 ns / 1 ps `include "Volume_Pregain_v1_0_tb_include.vh" // lite_response Type Defines `define RESPONSE_OKAY 2'b00 `define RESPONSE_EXOKAY 2'b01 `define RESP_BUS_WIDTH 2 `define BURST_TYPE_INCR 2'b01 `define BURST_TYPE_WRAP 2'b10 // AMBA AXI4 Lite Range Constants `define S00_AXI_MAX_BURST_LENGTH 1 `def...
#include <bits/stdc++.h> using namespace std; template <typename T> void UpdateMax(T& a, T b) { if (a < b) a = b; } template <typename T> void UpdateMin(T& a, T b) { if (a > b) a = b; } template <typename T> inline void read(T& x) { x = 0; char c = getchar(); int flag = 1; whil...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
/** * Copyright 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, k; priority_queue<pair<long long, pair<long long, long long>>> pq; long long divide(long long x, long long y) { if (x < y) return 1e16; long long t = x / y, rm = x % y; t += rm / y; rm %= y; return rm * (t + 1) * (t + 1) + (y - rm) *...
#include <bits/stdc++.h> using namespace std; const long double pi = acos(-1.0); long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } bool checkprime(long long n) { long long i = 2; while (i * i <= n) { if (n % i == 0) return 0; i++; } ret...
/* * 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 ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:11:01 10/17/2016 // Design Name: // Module Name: num_2 // Project Name: // Target Devices: // Tool versions: // Description: // // Dependenc...
#include <bits/stdc++.h> using namespace std; int n, k; long long mul[1005], c[1005][1005], f[1005][1005][2][3], chose[1005]; long long ans; int main() { scanf( %d%d , &n, &k); mul[0] = 1; for (int i = 1; i <= n; ++i) mul[i] = mul[i - 1] * (long long)i % 1000000007; for (int i = 0; i <= 1000; ...
// -- (c) Copyright 2011 - 2012 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...
#include <bits/stdc++.h> using namespace std; void solve(); int main() { solve(); } void solve() { int t; cin >> t; while (t--) { string s; cin >> s; priority_queue<int> q; int k = s.length(); int cur = (s[0] == 1 ) ? 1 : 0; for (int i = 1; i < k; 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...
/** * 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 = 1e9; const int MOD = 1e9 + 7; vector<string> vec_splitter(string s) { s += , ; vector<string> res; while (!s.empty()) { res.push_back(s.substr(0, s.find( , ))); s = s.substr(s.find( , ) + 1); } return res; } void ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; pair<int, int> c = make_pair(1, 0); int dx = 1, cover = 0, inc = 0; while (k != 1) { if (inc == 0) cout << 2 << ; if (dx == 1 && c.second + dx <= m) { c.second += dx; } else 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; int main() { char str1[10], str2[10], str3[10]; int flag1, flag2, flag3; flag1 = 0; flag2 = 0; flag3 = 0; cin >> str1 >> str2 >> str3; if (strcmp(str1, str2) == 0) { flag1 = 1; } else if (strcmp(str2, str3) == 0) { flag2 = 1; ...
#include <bits/stdc++.h> int main() { int t, arr[110], i, l, s, m, n, j; scanf( %d , &t); l = -1; s = 1001; for (i = 0; i < t; i++) scanf( %d , &arr[i]); for (i = 0; i < t; i++) { for (j = i + 1; j < t; j++) { if (arr[j] < arr[i]) { s = arr[j]; arr[j] = arr[i]...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f, oo = inf; inline long long read() { register long long x = 0; char f = 0; register char c = getchar(); for (; !isdigit(c); c = getchar()) f |= (c == - ); for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ ...
#include <bits/stdc++.h> using namespace std; int main() { long long t, s, a, b, c; cin >> t; for (int i = 0; i < t; i++) { cin >> s >> a >> b >> c; cout << s / c + ((s / c) / a) * b << endl; } return 0; }
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:60000000 ) using namespace std; const long double eps = 1e-9; const int inf = (1 << 30) - 1; const long long inf64 = ((long long)1 << 62) - 1; const long double pi = 3.1415926535897932384626433832795; const string task = ; template <class T> T...
`include "defines.v" module div( input wire clk, input wire rst, input wire signed_div_i, input wire[31:0] opdata1_i, input wire[31:0] opdata2_i, input wire start_i, input wire annul_i, output reg[63:0] ...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2012 Clifford Wolf <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * T...
#include <bits/stdc++.h> using namespace std; int n; int x[100000]; int dist(int a, int b) { return abs(a - b); } int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; cout << dist(x[0], x[1]) << << dist(x[0], x[n - 1]) << endl; for (int i = 1; i < n - 1; i++) co...
//////////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2014, University of British Columbia (UBC); All rights reserved. // // // // Redistribution and use in source and binary forms, w...
#include <bits/stdc++.h> using namespace std; string express(int layers) { string ans = ; for (int i = 1; i <= layers; i++) { if (i % 2 == 1) { if (i == layers) { ans += I hate it ; } else { ans += I hate that ; } } else { if (i == layers)...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2020 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t(/*AUTOARG*/ // Inputs clk ); input clk; int cyc = 0; // Test loop always ...
#include <bits/stdc++.h> using namespace std; const int N = (1 << 20) + 69; int heap[N], idx[N], val[N]; int g, h; void dream(int curr) { while (curr < ((1 << (h - 1)) - 1) && heap[curr] > min(heap[2 * curr + 1], heap[2 * curr + 2])) { int& left = heap[2 * curr + 1]; int& right = he...
/* * 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; long long solve(int N, const vector<int>& A) { long long res = 0; vector<int> freq(32); for (int x : A) { int hsb = (sizeof(int) * 8 - 1 - __builtin_clz((x))); res += freq[hsb]; ++freq[hsb]; } return res; } int main(int argc, ch...
//Legal Notice: (C)2010 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 do...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq * * 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, version 3 of the License. * * This program is dis...
#include <bits/stdc++.h> using namespace std; void solve() { int k, a, b; cin >> k >> a >> b; string s; cin >> s; int l = s.length(); double c = (double)l / k; int c1 = floor(c); int c2 = ceil(c); int flag1 = 0, flag2 = 0; if ((l - (c1 * (k - 1))) > b || (l - (c1 * (k - 1))) ...
#include <bits/stdc++.h> using namespace std; int mat[(int)1e3][(int)1e3], n; int dp2[(int)1e3][(int)1e3]; int dp5[(int)1e3][(int)1e3]; int changeRow[] = {1, 0}; int changeCol[] = {0, 1}; int pw2[(int)1e3][(int)1e3], pw5[(int)1e3][(int)1e3]; string dir[] = { D , R }; int pwr(int n, int k) { int 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...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; scanf( %d , &n); int arr[n]; for (i = 0; i < n; i++) scanf( %d , &arr[i]); int t = 0; int index = -1; for (i = 0; i < n; i++) if (arr[i] - arr[(i + 1) % n] > 0) { t++; index = i; } if ...
#include <bits/stdc++.h> using namespace std; const int mxn = 1e6 + 6; int n, r, c, t = 1, fr[mxn], nxt[mxn], ans[mxn]; char s[6 * mxn]; inline void dfs(int x) { if (!x) return; dfs(x >> 1); for (int i = 1; i <= n; ++i) { ans[i] = ans[ans[i]]; if (x & 1) ans[i] = nxt[ans[i]]; } }...
#include <bits/stdc++.h> using namespace std; int n, ans = 0; long long int mn = int(1e9); vector<int> c, d; vector<vector<pair<int, int>>> g; void dfs(int u, int p = 1) { d[u] = 1; for (auto v : g[u]) if (v.first != p) { dfs(v.first, u); d[u] += d[v.first]; } return;...
//Legal Notice: (C)2022 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 do...
#include <bits/stdc++.h> using namespace std; const int MX = 400005; template <typename T> void cmin(T &x, const T &y) { if (y < x) x = y; } template <typename T> void cmax(T &x, const T &y) { if (y > x) x = y; } template <typename T> void read(T &x) { x = 0; char c = getchar(); ...
#include <bits/stdc++.h> using namespace std; int rec[2][8]; int pattern[2][5500]; int n1, n2, z; int modpow(int n, int ex) { int res = 1; while (ex > 0) { if (ex % 2 == 1) res = (res * n) % 1000000007; n = (n * n) % 1000000007; ex = ex / 2; } return res; } void solve(int...
//***************************************************************************** // (c) Copyright 2008 - 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 property /...
#include <bits/stdc++.h> using namespace std; int read() { int x = 0; char ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 0 ), ch = getchar(); return x; } const int N = 1e7 + 5; const long long mod = 998244353; int ksm(int a, int...
module ExampMain #(parameter P) (input i, output o, inout io); endmodule module ExampStub (/*AUTOARG*/ // Outputs o, // Inouts io, // Inputs i ); /*AUTOINOUTPARAM("ExampMain")*/ // Beginning of automatic parameters (from speci...
#include <bits/stdc++.h> using namespace std; long long calc(long long n, long long k) { long long a = 1, b = 1, c; for (long long i = 1; i <= k; i++) a = a * (n - i + 1), b = b * i; if (k == 4) c = 9; else if (k == 3) c = 2; else if (k == 2) c = 1; else c = 0; re...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const long long N = 2e5 + 1; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; vector<long long> nums(n); for (long long i = 0; i < n; i++) { long long k; cin >> ...
#include <bits/stdc++.h> using namespace std; int n, num[105], ans = 0, i; int main() { scanf( %d , &n); for (int j = 1; j <= n; ++j) scanf( %d , &num[j]); if (n % 2 == 0 || n < 3) { printf( -1 n ); return 0; } for (int i = n; i >= 3; i -= 2) { int max_n = max(num[i], num[i -...
`include "defines.v" `timescale 1ns/1ps module tb( input `control_w port0_ci, input `data_w port0_di, output `control_w port0_co, output `data_w port0_do, input `control_w port1_ci, input `data_w port1_di, output `control_w port1_co, output `data_w port1_do, input `control_w port2...
/* * 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 = (int)3e5, maxM = (int)2e3, intMax = INT_MAX, maxValue = (int)1e4, intInf = (int)1e9, mod = (int)1e9 + 7, www = 97; const long long llmax = LLONG_MAX, INF = (long long)1e9 + 1; long long nod(long long a, long long b) { while (a != 0 &...
#include <bits/stdc++.h> using namespace std; int root; void addEdge(vector<int> adj[], int u, int v) { if (u == -1) { root = v; return; } adj[u].push_back(v); } int main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); vector<int> res; int n...
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, pair<int, int> > tab; int main() { int n, v[3]; pair<int, int> ans; int maior = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d%d%d , &v[0], &v[1], &v[2]); sort(v, v + 3); for (int j = 0; j < 3; j+...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; if (s.size() >= 1 && s.size() <= 100) { int i, j, k = 0, m = 0; for (i = 0; i < s.size(); i++) { if (s[i] >= a && s[i] <= z ) k++; if (s[i] >= A && s[i] <= Z ) m++; } if (k >= m) ...
module barrier_wait (/*AUTOARG*/ // Outputs tracemon_barrier_retire_en, fetch_wg_wfid, barrier_wait_arry, tracemon_barrier_retire_wf_bitmap, tracemon_barrier_retire_pc, // Inputs clk, rst, f_decode_valid, f_decode_barrier, f_decode_wfid, f_decode_instr_pc, fetch_wg_wgid, fetch_wg_wf_count ); /...
#include <bits/stdc++.h> using namespace std; int m; void Add(int &a, int b) { a += b; if (a >= m) a -= m; } int dp[1010][110][2]; int main() { int n, k; while (scanf( %d%d%d , &n, &k, &m) == 3) { memset(dp, 0, sizeof(dp)); dp[0][0][0] = 1; long long tmp = 1; for (int...
#include <bits/stdc++.h> using namespace std; int main() { int n, a; cin >> n >> a; if (a % 2 != 0) { cout << (((a - 1) / 2) + 1) << n ; } else { cout << ((n / 2) - ((a - 2) / 2)) << n ; } }
#include <bits/stdc++.h> using namespace std; template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << { ; string sep; for (const auto& x : v) os << sep << x, sep = , ; return os << } ; } template <typename T, size_t size> ostream& operator<<(ostream& os, const ...
#include <bits/stdc++.h> using namespace std; struct LazySegTree { int size; vector<long long> seg, delay; LazySegTree() {} LazySegTree(int size) { this->size = size; seg.resize(1 << (size + 1)); delay.resize(1 << (size + 1)); } long long Ident() { return 0; } long long...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int n, q, fa[N]; double p[N], sum[N], ans; vector<int> son[N]; void dfs(int x, int f) { fa[x] = f; for (int i = 0; i < son[x].size(); ++i) { int y = son[x][i]; if (y == f) continue; dfs(y, x); sum[x] += 1 - ...
#include <bits/stdc++.h> using namespace std; long long mod; long long power(long long a, long long p) { long long res = 1; while (p) { if (p & 1) res = res * a % mod; a = a * a % mod; p >>= 1; } return res; } long long inv(long long a) { return power(a, mod - 2); } class m...
/* * Asynchronous read 1r1w content addressable memory module. * Each entry has a tag and a data associated with it, and can be * independently cleared and set * - Read searches the array for any data with r_tag_i * - Write allocates a new entry, replacing an existing entry with replacement * scheme repl_sc...
/* * 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 = 1e5 + 5; const int mod = 1e9 + 7; void solve() { long long v1, v2, t, d; cin >> v1 >> v2 >> t >> d; long long ans = 0; for (int i = 0; i < t; i++) ans += min(v1 + d * i, v2 + (t - i - 1) * d); cout << ans << endl; } 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 law...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long n, k, m, f[100005][15][20]; long long count(long long x) { long long sum = 0; while (x) sum++, x -= (x & -x); return sum; } signed main() { scanf( %lld%lld%lld , &n, &k, &m); f[0][0][0] = 1; for (l...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; ; int bit; cin >> bit; ; int sum = 0; bool test = false; for (int i = 1; i < n; i++) { int h; cin >> h; ; bit -= (h + 1); if (bit < 0) { cout << NO ; return ...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFF = 0x3f3f3f3f3f3f3f3fll; const long long M = 1e9 + 7; const long long maxn = 1e5 + 7; const double eps = 0.00000001; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } template <typename ...
/** * 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 N = 2e5 + 1e3 + 7; int n, m, tot, root[N]; long long p, ans; struct node { int ls, rs; long long sum; } t[N * 30]; void insert(int x, int &y, int l, int r, int v) { y = ++tot; t[y] = t[x]; t[y].sum++; if (l == r) return; i...
#include <bits/stdc++.h> using namespace std; long long U[10001], V[10000], dis[10000]; long long n, m; vector<long long> adj[10001]; bool bfs() { queue<long long> q; for (long long i = 1; i <= n; i++) { if (U[i] == 0) { dis[i] = 0; q.push(i); } else dis[i] = INT_MA...
#include <bits/stdc++.h> using namespace std; vector<vector<long long int> > edge(100010); long long int vis[100010]; vector<long long int> color[2]; bool dfs(long long int a, long long int c = 2) { vis[a] = c; color[c - 1].push_back(a); for (auto x : edge[a]) { if (!vis[x] && dfs(x, 3ll - c...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f, N = 10; int ans = inf, n, k, idx[N]; char arr[N][N]; int convert(int num) { int ret = 0; for (int i = 0; i < k; ++i) { ret = (ret * 10) + (arr[num][idx[i]] - 0 ); } return ret; } int main() { cin >> n >> k...
#include <bits/stdc++.h> using namespace std; int n; int main() { ios_base::sync_with_stdio(false); while (cin >> n) { vector<int> inside(1000006, 0), ans; int stack = 0, length = 0, x, valid = 1, j = 1; unordered_map<int, int> used; for (int i = 0; i < n; ++i) { cin >> x; ...
module t (/*AUTOARG*/ // Inputs clk, reset_l ); input clk; input reset_l; reg inmod; generate if (1) begin // Traces as genblk1.ingen integer ingen; initial $display("ingen: {mod}.genblk1 %m"); end endgenerate integer raw...
#include <bits/stdc++.h> using namespace std; int in() { int x; scanf( %d , &x); return x; } long long lin() { long long x; scanf( %lld , &x); return x; } int x[200010]; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = in(); int...
#include <bits/stdc++.h> using namespace std; int n, m; int l[5005], r[5005], v[105][105], t[105][105]; double res[105], c[5005], f[105][105], cc[105][105]; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { int a, b, x; scanf( %d%d%d , &a, &b, &x); l[i] = (--a); ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cnt[1001] = {0}, a[n]; for (int i = 0; i < n; ++i) { cin >> a[i]; cnt[a[i]] = i; } int vis[1001] = {0}; vector<int> res; for (int i = 0; i < n; i++) { if (cnt[a[i]] == i) res.push_back(a...
#include <bits/stdc++.h> using namespace std; int s, n, m, t, x, y; vector<int> ord; vector<vector<int>> g; bool vis[200010]; void dfs(int c) { vis[c] = true; for (auto &v : g[c]) { if (!vis[v]) dfs(v); } ord.push_back(c); } int main() { std::istream::sync_with_stdio(false); ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long n, a[10], C[110][110], dp[110][10], ans; inline long long add(long long x, long long y) { x += y; if (x > MOD) x -= MOD; return x; } inline long long mul(long long x, long long y) { x *= y; if (x > MOD...
#include <bits/stdc++.h> using namespace std; const int maxn = 200008; int n, k, l, r; char g[2][maxn]; bool f[2][maxn]; struct arr { int t, s, x; } h[maxn]; bool Add(int t, int s, int x) { if (t >= x) return 0; if (x > n) return 1; if (f[s][x]) return 0; if (g[s][x] == X ) return 0...
#include <bits/stdc++.h> using namespace std; int n1, n2, k1, k2; long long aa[105][105][2]; long long foo(int u, int v, int a) { if (u == 0 && v == 0) { return 1; } if (u < 0 || v < 0) { return 0; } if (aa[u][v][a] != -1) return (aa[u][v][a]); long long s = 0; if (a) { ...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > g[100010]; int N, K, in[100010], dp[100010][2]; vector<pair<int, int> > num[100010]; void dfs(int u, int fa) { for (pair<int, int>& e : g[u]) { int v = e.first, cost = e.second; if (v == fa) continue; dfs(v, u); ...
#include <bits/stdc++.h> using namespace std; long long int arr[1000000]; int main() { int n; cin >> n; long long int count = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; } long long int Min = arr[0]; long long int Max = arr[0]; for (int i = 1; i < n; i++) { if (arr[...
`default_nettype none module reversed_gate (clk, ctrl, din, sel, dout); input wire clk; input wire [4:0] ctrl; input wire [15:0] din; input wire [3:0] sel; output reg [31:0] dout; always @(posedge clk) case ((({(32)-((ctrl)*(sel))})+(1))-(2)) 0: dout[1:0] <= din; 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...
/** * 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 cx[] = {-1, 0, 0, 1, -1, -1, 1, 1, 0}, cy[] = {0, -1, 1, 0, -1, 1, 1, -1, 0}; int ingrid(int ii, int jj, int R, int C) { if (ii < 0 || jj < 0 || ii >= R || jj >= C) return 0; return 1; } int main() { long long n; cin >> n; long long m...
#include <bits/stdc++.h> using namespace std; const long long N = 205, P = 1e9 + 7ll; struct node { long long x, y; node operator-(const node &t) const { node c; c.x = x - t.x; c.y = y - t.y; return c; } long long operator*(const node &t) const { return x * t.y - y * t.x; }...