text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { srand(time(0)); if (rand() % 2 == 0) cout << Odd ; else cout << Even ; }
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:55:04 12/14/2010 // Design Name: // Module Name: msu // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: // R...
#include <bits/stdc++.h> using namespace std; int a[150]; int b[150]; int n, k; string s; bool ok[400005], dem = -1; int main() { cin.tie(NULL); cin >> n >> k; cin.ignore(); cin >> s; for (int i = 1; i <= 50; i++) a[i] = 0; for (int i = 0; i < n; i++) { a[int(s[i]) - 96]++; ...
#include <bits/stdc++.h> using namespace std; inline int in() { int N = 0; register char c = getchar_unlocked(); while (c < 48 || c > 57) { c = getchar_unlocked(); } while (c > 47 && c < 58) { N = (N << 3) + (N << 1) + (c - 48); c = getchar_unlocked(); } return N; } ...
`timescale 1ns / 1ps module control(clk, lsb_B, init, Z, ld_rst, shift, acc, done); input clk; input lsb_B; input init; input Z; output reg ld_rst; output reg shift; output reg acc; output reg done; reg [2:0] current_state; reg [2:0] next_state; parameter start=3'b000, check=3'b001, acum=3'b010, shft=3'b0...
#include <bits/stdc++.h> using namespace std; const long long mod1 = 1e9 + 7, mod = 998244353; const long long N = 3e5 + 7; long long ncr[N]; void fact(long long A) { auto binexp = [&](long long a, long long b) { long long res = 1; while (b) { if (b & 1) res *= a; a *= a; ...
// Library - static, Cell - th44w3, View - schematic // LAST TIME SAVED: May 23 17:58:12 2014 // NETLIST TIME: May 23 17:58:31 2014 `timescale 1ns / 1ns module th44w3 ( y, a, b, c, d ); output y; input a, b, c, d; specify specparam CDS_LIBNAME = "static"; specparam CDS_CELLNAME = "th44w3"; specpar...
#include <bits/stdc++.h> bool m1; FILE *Input = stdin, *Output = stdout; const int maxn = 1e5 + 5; struct Edge { int to, next; Edge(){}; Edge(int ar1, int ar2) { to = ar1; next = ar2; } } Tree_List[maxn << 1], Tree2_List[maxn << 2]; int Numt[maxn], tott, deg[maxn], totn; int Nu...
#include <bits/stdc++.h> using namespace std; int main() { long long a[100000]; long long n, i; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); a[0] = 1; for (i = 1; i <= n - 1; i++) { if (a[i] == a[i - 1] || a[i] == a[i - 1] + 1) continue; ...
#include <bits/stdc++.h> using namespace std; int main() { pair<int, int> a, b, c; int s = 0; cin >> a.first >> a.second >> b.first >> b.second >> c.first >> c.second; s = a.first * a.second + b.first * b.second + c.first * c.second; if ((int)sqrt(s + 0.0) * (int)sqrt(s + 0.0) != s) { cout...
module Platform ( clk_clk, hex0_2_export, hex3_5_export, hps_io_hps_io_emac1_inst_TX_CLK, hps_io_hps_io_emac1_inst_TXD0, hps_io_hps_io_emac1_inst_TXD1, hps_io_hps_io_emac1_inst_TXD2, hps_io_hps_io_emac1_inst_TXD3, hps_io_hps_io_emac1_inst_RXD0, hps_io_hps_io_emac1_inst_MDIO, hps_io_hps_io_emac1_inst_MDC, h...
#include <bits/stdc++.h> using namespace std; int dp[500][500] = {0}, arr[500], n; int check(int i, int j) { if (dp[i][j] != 0) return dp[i][j]; if (i > j) return 0; if (i == j) { dp[i][j] = 1; return 1; } int a = 1 + check(i + 1, j); int m = 1e9, it; for (it = i + 2; it <=...
#include <bits/stdc++.h> using namespace std; template <typename T> T sgn(T x) { return x < 0 ? -1 : x != 0; } template <typename T> T gcd(T a, T b) { return a ? gcd(b % a, a) : b; } void reads(string& x) { char kk[((long long)5e2 + 123)]; scanf( %s , kk); x = kk; } long long n, ...
//Legal Notice: (C)2018 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...
/** * 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 k, n, a; int d[1001]; bool vis[1001], flag; int main() { scanf( %d%d , &n, &k); int cut = 0; for (int i = 2; i <= k; i++) { if (k % i) continue; int crt = 1; while (k % i == 0) { crt *= i; k /= i; } d[c...
#include <bits/stdc++.h> using namespace std; pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) { return make_pair(a.first + b.first, a.second + b.second); } pair<int, int> operator-(const pair<int, int> &a, const pair<int, int> &b) { return make_pair(a.first - b.first, a.second...
`timescale 1ns /1ps //Memory. module Memory( input wire [31:0] wData, input wire clk, input wire enable, input wire rw, input wire reset, input wire [9:0] add, output reg [31:0] rData ); reg [31:0] mem [1023:0]; integer i; always @(posedge clk) begin if (reset) begin for(i = 0; i < ...
#include <bits/stdc++.h> using namespace std; char s[5000005]; int len[1000005]; int idx[1000005]; int sum[1000005]; int sz = 0; int dp[1000005][20]; int p[1000005]; int main() { int n, r, c; scanf( %d%d%d , &n, &r, &c); gets(s); gets(s); int cnt = 0, slen = 0; 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 la...
#include <bits/stdc++.h> using namespace std; char str[1000001]; int main() { int n; scanf( %d , &n); scanf( %s , str); int sum = 0; int ln = -1; int i, j, k, ans = 0; for (i = 0; i < n; i++) { if (str[i] == ( ) { sum++; if (sum == 0) { ans += i - ln + ...
#include <bits/stdc++.h> using namespace std; long long ans; int n, a, b; vector<pair<int, int> > v; int main() { ans = 0; scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d %d , &a, &b); v.push_back(make_pair(b, a)); } sort(v.begin(), v.end()); for (int i = 0, j = 0;...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e6 + 4; bool isPrime(int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) retu...
/* * 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 clique_size(vector<int> *graph, vector<int> &govs, int *visited, int starting) { visited[starting] = 1; int size = 1; for (int i = 0; i < graph[starting].size(); i++) { if (!visited[graph[starting][i]]) { size += clique_si...
/* * 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...
module peripheral_adc(input clk_in, input cs, input wr input rd, input din, input rst, input reg [3:0]addr, output reg [7:0]d_out, output clk_di...
// Copyright (c) 2015 CERN // Maciej Suminski <> // // 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 late...
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; cin>>t; while(t--){ int xa,ya,xb,yb,xf,yf; cin>>x...
#include <bits/stdc++.h> using namespace std; struct mat { int num[4][4]; }; int p[100009]; mat mult(mat &a, mat &b) { mat ret; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) { long long t = 0; for (int k = 0; k < 4; k++) t += 1ll * a.num[i][k] * b.num[k][j]; ...
//----------------------------------------------------------------- // RISC-V Top // V0.6 // Ultra-Embedded.com // Copyright 2014-2019 // // // // License: BSD //--------------------------...
/** * 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 mod = 1e9 + 7; inline long long read() { long long x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = x * 10 + c - 0 ; c ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:45:55 04/23/2017 // Design Name: // Module Name: decrypt_tb // Project Name: // Target Devices: // Tool versions: // Description: // // Depe...
/* * 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; scanf( %d n , &n); string str; getline(cin, str); int ans = 0; int subans = 0; for (int i = 0; i < n; i++) { if (str[i] != ) { int ascii = (int)str[i]; if (ascii >= 65 && ascii <= 90) { s...
`include "mpc4922.v" `include "lineto.v" module top( output led_r, output led_b, output gpio_2, // cs output gpio_46, // clk output gpio_47 // do ); wire reset = 0; wire clk_48mhz, clk = clk_48mhz; SB_HFOSC osc(1,1,clk_48mhz); reg [11:0] lineto_x; reg [11:0] lineto_y; reg lineto_strobe; wire lineto_read...
module InterruptController ( input wire rst, input wire clk, input wire fastClk, output reg irq, input wire turnOffIRQ, output reg[31:0] intAddr, output reg[15:0] intData, inout wire ps2CLK, inout wire ps2DATA, input wire[31:0] addr, input wire re, input wire we, inp...
// 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 agreed...
/* * 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...
//wishbone_interconnect.v /* Distributed under the MIT licesnse. Copyright (c) 2011 Dave McCoy () 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...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> rs; if (n == 1) { rs.push_back( a ); rs.push_back( a ); rs.push_back( b ); rs.push_back( b ); } else if (n == 2) { rs.push_back( aa ); rs.push_back( bb ); rs.push_...
#include <bits/stdc++.h> using namespace std; long long n, k, ar[1000005], br[1000005]; int main() { scanf( %lld %lld , &n, &k); long long min_ = 0, max_ = 0; for (int i = 1; i < n + 1; i++) { ar[i] = br[i] = i; min_ += i; max_ += max((long long)i, n - i + 1); } if (k < min_)...
// // TV80 8-Bit Microprocessor Core // Based on the VHDL T80 core by Daniel Wallner () // // Copyright (c) 2004 Guy Hutchison () // // 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 witho...
/* 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...
// Copyright 1986-2017 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2017.3 (win64) Build Wed Oct 4 19:58:22 MDT 2017 // Date : Fri Nov 17 14:50:02 2017 // Host : egk-pc running 64-bit major release (build...
/* * Copyright (c) 2000 Stephen Williams () * * 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 main() { string s; int fl = 1; cin >> s; for (int i = 0; i < s.size(); ++i) { if (s[i] == 1 || s[i] == 2 ) fl = 0; else if (s[i] == 3 && s[s.size() - i - 1] != 3 ) fl = 0; else if (s[i] == 7 && s[s.size() - 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; void solve() { long long n; cin >> n; vector<long long> a(n + 1), b(n + 1); for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; long long k; cin >> k; long long x; for (int i = 1; i <= n; i++) if (k >= a[i] && k <= b[i]) { x =...
#include <bits/stdc++.h> using namespace std; int k, t; char n1[10005]; char n2[10005]; int swapindex[2]; bool same(char x[], char y[], int n) { for (int i = 0; i < n; i++) { if (x[i] != y[i]) { return false; } } return true; } int ham(char x[], char y[], int n) { int...
////////////////////////////////////////////////////////////////////// //// //// //// OR1200's IC RAMs //// //// //// //// This file is part of the OpenR...
#include <bits/stdc++.h> using namespace std; bool isPrime(long long int n) { for (long long int i = 2; i <= sqrt(n); i++) if (n % i == 0) return 0; return 1; } long long knap_0_1(long long wt[], long long val[], long long n, long long w) { long long kp[n + 1][w + 1]; for (long long i = 0;...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2003-2007 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; reg [7:0] cyc; initial cyc = 0; ...
#include <bits/stdc++.h> using namespace std; const double inf = 1e9; const double eps = 1e-7; int main() { int n, width, height, begin0, begin1; cin >> n >> width >> height >> begin0 >> begin1; vector<pair<int, pair<double, double>>> a(n + 1); a[0] = make_pair(0, make_pair(1, begin1 - begin0));...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
//----------------------------------------------------- // This is 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_...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using ll = long long int; using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c *x) -> decltype(cerr << *x, 0); template <class c...
`include "shiftRegister.v" `include "memory.v" `include "finiteStateMachine.v" `include "programCounter.v" `include "serialClock.v" `include "mosiFF.v" `include "delayCounter.v" module toplevel(led, gpioBank1, gpioBank2, clk, sw, btn); // possible inputs from fpga output [7:0] led; output [3:0] gpioBank1; output [3:0]...
`include "core.h" `default_nettype none module decode_authcheck( input wire [31:0] iINSTRUCTION, input wire iKERNEL_ACCESS, input wire [13:0] iMMU_FLAGS, output wire [2:0] oIRQ41 ); /************************************************* Instruction Check [0] : IRQ41 Privilege error.(Page) **************...
// Copyright 2006, 2007 Dennis van Weeren // // This file is part of Minimig // // Minimig 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 // (at your option) any later ve...
#include <bits/stdc++.h> using namespace std; int pos[100005]; pair<int, int> tree[100005]; bool func(pair<int, int> x, pair<int, int> y) { return (x.first) < (y.first); } int main() { int n; for (int i = 1; i < 100005; i++) { pos[i] = 2e9 + 1000; } pos[0] = -2e9; scanf( %d , &n); ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (a < b) swap(a, b); cout << b << << (a - b) / 2 << endl; }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 3; const long long MOD = 1e9 + 7; const long long INF = 2e9; const int fullmask = (1 << 10) - 1; long long fpow(int n, int p) { if (!p) return 1; if (p == 1) return n; long long tmp = fpow(n, p / 2); if (p & 1) return tmp * tm...
/* 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...
/* * 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...
//-------------------------------------------------------------------------- // -- // OneWireMaster -- // A synthesizable 1-wire master peripheral -- // Copyrig...
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 10; const int INF = int(1e9); int main() { int n; char str1[maxn], str2[maxn]; while (~scanf( %d , &n)) { scanf( %s %s , str1, str2); int h, m; h = (str1[0] - 0 ) * 10 + str1[1] - 0 ; m = (str2[0] - 0 ) *...
//----------------------------------------------------------------------------- // File : spi_master.v // Creation date : 10.04.2017 // Creation time : 15:38:03 // Description : A minimalistic example for SPI master IP-XACT document. // Created by : TermosPullo // Tool : Kactus2 3.4.20 32-bit // Plugin : ...
#include <bits/stdc++.h> using namespace std; int main() { int r, c, x = 0, y, z; cin >> r >> c; while (r != 0) { if (r % 2 != 0) { for (int i = 0; i < c; i++) { cout << # ; } cout << n ; } else { if (!x) { for (int i = 0; i < c - 1; i++...
#include <bits/stdc++.h> using namespace std; template <typename T> inline string tostring(const T &x) { ostringstream os; os << x; return os.str(); } inline int toint(const string &s) { istringstream is(s); int x; is >> x; return x; } inline int todecimal(string s) { int a...
/* * 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 INFint = 2147483647; const long long INF = 9223372036854775807ll; const long long MOD = 1000000007ll; const long double EPS = 1e-9; int p[1000]; int a[1000]; int b[1000]; int cnt; void dfs(int v) { p[v] = 1; for (int i = 1; i <= cnt; i+...
//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...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int u, v; cin >> u >> v; if (u > v) printf( NO n ); else if (u == v) ...
/* * Palette register file for VGA * Copyright (C) 2010 Zeus Gomez Marmolejo <> * * VGA FML support * Copyright (C) 2013 Charley Picker <> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU Genera...
/** * 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 maxlongint = 2147483647; const int inf = 1000000000; int main() { int a, b, c, d, e, f, ans = 0, k = -1, n1, n2; cin >> a >> b >> c >> d >> e >> f; ans = a * b + c * d + e * f; for (n1 = 1; n1 <= 1000; n1++) if (n1 * n1 == ans) { ...
/* * 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, m; vector<vector<char>> grid; pair<int, int> start, endloc; int memo[1000][1000][4]; bool dfs(pair<int, int> loc, int turns, int dir) { if (loc == endloc) return true; memo[loc.first][loc.second][dir] = turns; vector<pair<int, int>> next; ...
/** * 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) 2005 by Terasic Technologies Inc. // -------------------------------------------------------------------- // // Permission: // // Terasic grants permission to use and modify this code for use // in synthesis for all Terasic De...
/* * Titor - System - Simple counter that rolls over at a specified value that can be chained with different radixes * Copyright (C) 2012 Sean Ryan Moore * * 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 *...
#include <bits/stdc++.h> using namespace std; int main() { long long i, n, r, S, Z, s1, s2, s3, s4, s5, s6, s7, s8, x, y, z, m, j, l, k, t; long long a[500005]; long long b[300045]; long long c[300001]; long long d[100001]; long long e[101][101]; pair<long long, long long> aa[200...
#include <bits/stdc++.h> using namespace std; int main() { int n; while (scanf( %d , &n) == 1) { string s; cin >> s; s = # + s; bool used[n + 1]; memset(used, 0, sizeof used); int d[n + 1]; for (int i = 1; i <= n; i++) { scanf( %d , d + i); } i...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; const int mxN1 = 1e5, mxN2 = 1 << 18, INF = 1e9; struct dat { int len = 0, max; vector<pair<int, int>> pref, suf; } tree[mxN2]; int n, q, qt; string ss[mxN1]; inline void cmb(dat &d, dat &a, dat &b) { d.len = a.len + b.len; d.max = max(a.max, b...
/** * 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> long long memo[100005][205]; std::pair<long long, int> pre[100005]; int n; struct q4 { int s, t, d, pin; long long w; bool operator<(const q4& wx) const { return ((w > wx.w) || ((w == wx.w) && (d > wx.d))); } }; std::vector<q4> Q[100005]; std::multiset<q4> X;...
/** * 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...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 10:10:52 08/30/2014 // Design Name: // Module Name: lab4dpath // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // ...
#include <bits/stdc++.h> int ar[100000]; using namespace std; int main() { int n; cin >> n; int c = 0, ans = 0; int r; for (int i = 0; i < 2 * n; i++) { cin >> r; if (ar[r]) { ar[r] = 0; c--; } else { c++; ar[r] = 1; } if (ans < c) ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using pii = pair<int, int>; constexpr int N = 300001; struct Ed { int u, v; bool s; }; vector<pii> g[N], t[N]; int d[N], low[N], biconn[N]; bool scored[N], vis[N]; ...
#include <bits/stdc++.h> #pragma GCC target( fma ) #pragma GCC optimize( unroll-loops,-Ofast ) using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long a[500005]; int n; set<long long> buck[1000]; long long c[1000]; void fix(int v) { int l = v * 700; ...
#include <bits/stdc++.h> using namespace std; signed solve(); signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int tests = 1; while (tests--) solve(); return 0; } signed solve() { int n, k; cin >> n >> k; if (n <= 1ll * k * (k - 1)) { ...
#include <bits/stdc++.h> using namespace std; long long n; int x[100005], y[100005], num_, num; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; if (x[i] > 0) { num++; } else { num_++; } } if (num == 1 || num_ == 1 || num == 0 || n...
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; template <typename T> void readv(vector<T>& v, int n) { for (int i = 0; i < n; ++i) { T tmp; cin >> tmp; v.push_back(tmp); } } struct cmp { bool operator()(const pair<int, int>& i1, const pair<int, int>& i2) ...
#include <bits/stdc++.h> using namespace std; long long int cnt(long long int x) { long long int ans = 0; while (x) { x /= 2; ans++; } return ans; } int main() { int t; cin >> t; while (t--) { long long int d, m; cin >> d >> m; long long int temp = cnt(d...
#include <bits/stdc++.h> using namespace std; const int maxn = 100050, maxm = 5050; int n, m, K, p, h[maxn], a[maxn]; long long hh[maxn], ans; long long tim[maxn]; int cnt[maxm]; bool judg(long long x) { int i, j; long long tis = 0; for (i = 0; i < m; i++) cnt[i] = 0; for (i = 0; i < n; i+...
// (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...