text
stringlengths
59
71.4k
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of ent_t // // Generated // by: wig // on: Tue Jun 27 05:12:12 2006 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl ../verilog.xls // // !!! Do not edit this file! Autogenerated by MIX !!! // $Author: wi...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2020 by engr248. // SPDX-License-Identifier: CC0-1.0 module t(/*AUTOARG*/ // Inputs clk ); input clk; wire [31:0] in = 0; wire [31:0] out; Tes...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; int input[n]; for (int i = (0); i < (n); i++) cin >> input[i]; sort(input, input + n); vector<int> ans(n); ...
/** * 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 a, b, c, x, y, z, e, s, max1, max2, max3, max4; cin >> a >> b >> c; x = a + b * c; y = a * (b + c); z = a * b * c; e = (a + b) * c; s = a + b + c; max1 = (x + y + abs(x - y)) / 2; max2 = (max1 + z + abs(max1 - z)) / 2...
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 6; const long long MOD = 1e9 + 7; int a[56]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, cnt = 0, mn = 50; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; mn = min(mn, a[i...
/****************************************************************************** * License Agreement * * * * Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. * ...
#include <bits/stdc++.h> using namespace std; struct __s { __s() { if (1) { ios_base::Init i; cin.sync_with_stdio(0); cin.tie(0); } } ~__s() { if (!1) fprintf(stderr, Execution time: %.3lf s. n , (double)clock() / CLOCKS_PER_SEC); ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:20000000 ) using namespace std; int main() { int n, m; cin >> n >> m; vector<string> a; string s; for (int i = (0); (i) < (n); (i)++) { cin >> s; a.push_back( # + s + # ); } int x = 1; long long r = 0; bool ...
#include <bits/stdc++.h> using namespace std; int X; vector<int> E[100010]; int all, all2; int v[800 + 10]; int dp[800 + 10], dp2[800 + 10]; void calc(int x) { for (int i = 0; i <= 800 - 1; ++i) v[i] = 0; for (int i = 0; i < E[x].size(); ++i) v[E[x][i]] = 1; for (int i = 0; i <= 800 - 1; ++i) ...
// Copyright (c) 2014 Takashi Toyoshima <>. // All rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. `timescale 100ps/100ps module SerialReceiverTest; reg clk; reg rst_x; reg rx; wire [7:0] w_data; wire w_valid;...
#include <bits/stdc++.h> using namespace std; long long dp[2][55]; long long m[55]; long long n; int main() { cin >> n; for (long long i = 0; i < n; i++) { cin >> m[i]; } for (long long i = n - 1; i >= 0; i--) { dp[0][i] = max(dp[1][i + 1] + m[i], dp[0][i + 1]); dp[1][i] = mi...
/** * 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; bool isPrime(long long n) { if (n <= 1) return false; for (int i = 2; i <= sqrt(n); i++) if (n % i == 0) return false; return true; } long long factorial(long long n) { if (n == 0) return 1; else return n * factorial(n - 1); }...
#include <bits/stdc++.h> using namespace std; int n, t, tt, sz, res = 1e9, a[55][100005], out[100005], cnt[100005], mul[100005], que[1000005]; int read() { int x = 0, fl = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) fl = -1; ch = getchar(); ...
#include <bits/stdc++.h> using namespace std; int n, m, d; int a[305]; long long t[305]; int dp[2][150005]; struct que { int i, num; que(int I, int NUM) { i = I, num = NUM; } friend bool operator<(struct que A, struct que B) { return A.num > B.num; } }; int compute() { int s0 = 0, s1 = 1...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Mon Apr 10 13:17:00 2017 // Host : LAPTOP-IQ9G3D1I running 64-bit major releas...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using u32 = unsigned int; using db = double; using ld = long double; using pii = std::array<int, 2>; using pll = std::array<ll, 2>; const int INF = 0x3f3f3f3f; const long long INFll = 0x3f3f3f3f3f3f3f...
#include <bits/stdc++.h> using namespace std; int mod = 1000000007; int dv[1000005]; int cnt[1000006]; inline void add(int &r, int a) { r += a; if (r >= mod) r -= mod; } int mPow(int a, int x) { int ret = 1; while (x > 0) { if (x & 1) ret = 1LL * ret * a % mod; a = 1LL * a * 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 la...
// (C) 1992-2014 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 simulati...
// (C) 2001-2018 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 from any of the foregoing (including device programming or simulation // files), and any associated ...
/** * 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 p = 1000000007; int pow3[10]; int main() { pow3[0] = 1; pow3[1] = 3; pow3[2] = pow3[1] * 3; pow3[3] = pow3[2] * 3; pow3[4] = pow3[3] * 3; pow3[5] = pow3[4] * 3; pow3[6] = pow3[5] * 3; map<char, int> myMap; char c; lo...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k = 0, k1 = 0, kol1 = 0, kol2 = 0; cin >> n >> m; int a[n + 10], b[m + 10]; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] % 2 == 1) k++; ...
`timescale 1ns/1ns module udp_outbound_chain_tx (input c, input [7:0] rxd, input rxdv, output [7:0] txd, output txdv); localparam SW = 5, CW = 5; reg [CW+SW-1:0] ctrl; wire [SW-1:0] state; wire [SW-1:0] next_state = ctrl[SW+CW-1:CW]; r #(SW) state_r (.c(c), .rst(1'b0), .en(1'b1), .d(next_sta...
// Code your design here //////////////////////////////////////////////////////////////////////////////////////////////////7 // Module: control_DAT // Projecto: SD Host // // Descripcion: Modulo de control para el bloque DAT del SD Host , este modulo controla las señales para solicitud de un nuevo servicio , e...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); string t; cin >> t; int n = t.size(); int start = (n % 2) ? n / 2 : n / 2 - 1; int j = 1; int k = n / 2; putchar(t[start]); while (k--) { if (start + j <= n - 1) { pu...
#include <bits/stdc++.h> using namespace std; long long arr[300000]; long long temp[300000]; int main() { int q; cin >> q; while (q--) { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; temp[i] = arr[i]; } int st = 0; int endIdx1 = -1;...
/* * File: pippo_barrel.v * Project: pippo * Designer: kiss@pwrsemi * Mainteiner: kiss@pwrsemi * Checker: * Assigner: * Description: barrel shifter * Task.I * ¶àÖÜÆÚ²ÎÊý»¯ */ module pippo_barrel ( shift_in, shift_cnt, insert_in, mask_begin, mask_end, shift_left, ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1760777216 ) using namespace std; const double Pi = 3.14159265358979323846; int main() { int T; scanf( %d , &T); while (T--) { double R, r, k; scanf( %lf%lf%lf , &R, &r, &k); double x1 = 0.5 / R, x2 = 0.5 / r, rr = fabs(x1 - ...
//% @file Top_SR.v //% @brief TMIIa shift register control module. //% @author pyxiong //% //% This module generates shift register control signals, //% and receives the output data of TMIIa shift register . //% This module is controlled by a high frequency clock clk_in, //% it sends parallized data(din) to shift regi...
#include <bits/stdc++.h> using namespace std; int a[100000]; int b[100000]; int main() { int n, m, y0, y1; cin >> n >> m >> y0 >> y1; for (int x = 0; x < n; ++x) { cin >> a[x]; } for (int x = 0; x < m; ++x) { cin >> b[x]; } int i = 0, j = 0, pp = -1; int kk = 0; f...
`timescale 1 ns / 1 ps module AXIOutputRegisters_v1_0 # ( // Users to add parameters here // User parameters ends // Do not modify the parameters beyond this line // Parameters of Axi Slave Bus Interface S00_AXI parameter integer C_S00_AXI_DATA_WIDTH = 32, parameter integer C_S00_AXI_ADDR_WIDTH = 6 ...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003 Matt Ettus // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License...
/** * 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 maxn = 155; int f[maxn][maxn * maxn], a[maxn]; int n, K, s, ans = 2e9, cur; void solve() { sort(a + 1, a + n + 1); ans = 0; for (int i = 1; i <= K; i++) ans += a[i]; printf( %d n , ans); } int main() { scanf( %d%d%d , &n, &K, &s);...
#include <bits/stdc++.h> using namespace std; int gcd(long long a, int b) { if (a < b) { return gcd(b, a); } if (b == 0) { return a; } return gcd(b, a % b); } class Triplet { public: long long gcd; long long x; long long y; }; Triplet gcdExtendedEuclid(int a, i...
// 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 // 5 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 //---------------------------------------------------------------------------------------- // // The MIT License (MIT) // Copyright (c) 20...
#include <bits/stdc++.h> using namespace std; template <class T> string i2s(T x) { ostringstream o; o << x; return o.str(); } template <class T> vector<T> split(const string& s) { vector<T> v; istringstream is(s); T t; while (is >> t) v.push_back(t); return v; } vector<st...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int T; cin >> T; while (T--) { long long n, k; cin >> n >> k; if (k % 3) { if (n % 3) cout << Alice n ; else cout << ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a, b; int t = n / 2; if (n % 2 == 1) { cout << t << << t + 1; } else if (n % 4 == 2) { cout << t - 2 << << t + 2; } else if (n % 4 == 0) { cout << t - 1 << << t + 1; } }
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2003 by Wilson Snyder. module t; // verilator lint_off LITENDIAN reg [5:0] binary_nostart [2:15]; reg [5:0] binary_start [0:15]; reg [175:0] hex [0:15]; // verilator l...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000003ll; long long npow[64]; long long fast_pow(long long n, long long e) { if (e == 0) return 1ll; long long tmp = fast_pow(n, e / 2ll); tmp = (tmp * tmp) % MOD; if (e & 1ll) return (tmp * n) % MOD; return tmp; } int ...
#include <bits/stdc++.h> using namespace std; int f(char c1, char c2) { if (c1 == R && c2 == S ) return 1; if (c1 == S && c2 == P ) return 1; if (c1 == P && c2 == R ) return 1; if (c2 == R && c1 == S ) return -1; if (c2 == S && c1 == P ) return -1; if (c2 == P && c1 == R ) ...
#include <bits/stdc++.h> using namespace std; int number[120], prime[120], primecounter = 0; void sieve() { for (int i = 0; i <= 100; i++) number[i] = 1; number[0] = 0; number[1] = 0; for (int i = 4; i <= 100; i = i + 2) number[i] = 0; for (int i = 3; i * i <= 100; i = i + 2) { for (int ...
/** * 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 inf = (long long)1e18; const long long mod = (long long)1e9 + 7; const double eps = (double)1e-9; const double pi = acos(-1.0); const int dx[] = {0, 0, 1, 0, -1}; const int dy[] = {0, 1, 0, -1, 0}; const int N = 300500; int main() { cin...
#include <bits/stdc++.h> using namespace std; vector<pair<pair<int, int>, int>> ordered; deque<pair<int, int>> solutions; vector<bool> stay, check; bool cmp(pair<pair<int, int>, int> &a, pair<pair<int, int>, int> &b) { int A = a.first.second - a.first.first; int B = b.first.second - b.first.first; ...
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; cout << (n - 1) / 2 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int MAXN = (int)1003; const int LOG = (int)11; const int infint = (int)1e9 + 3; const long long inf = (long long)1e12; string A, B[MAXN]; int cost[MAXN], dp[MAXN][MAXN], last[MAXN], n, mx, sza; pair<int, int> radix[MAXN]...
//Legal Notice: (C)2013 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 law...
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y; int p = 1; cin >> n; cin >> x; cin >> y; p = n * y; if (p % 100 != 0) p = p / 100 + 1; else p = p / 100; if (p <= x) cout << 0 << endl; else cout << p - x << endl; return 0; ...
#include <bits/stdc++.h> using namespace std; int main() { static int f[10000]; int n, ok = false; scanf( %d , &n); for (register int i = 1; i <= n; ++i) scanf( %d , f + i); for (int i = 1; i <= n; ++i) if (f[f[f[i]]] == i) ok = true; puts(ok ? YES : NO ); }
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; char s[1010]; int n, fa[2010], val[2010], pw2[2010], ans = 0; inline int getf(int x) { if (x == fa[x]) return x; int f = getf(fa[x]); val[x] ^= val[fa[x]]; fa[x] = f; return f; } inline int merge(int x, int y, int...
// VGA_0.v // This file was auto-generated as part of a SOPC Builder generate operation. // If you edit it your changes will probably be lost. `timescale 1 ps / 1 ps module VGA_0 ( input wire iCLK, // clk.clk output wire [9:0] VGA_R, // avalon_slave_0_export.export outpu...
/** * 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 N = 2e5 + 1; const long long nol = 0; long long n, k, a, cnt, ans, j, mx; deque<long long> v, vc; void vkoshp() { cin >> n >> k; for (long long i = 0; i < n; i++) { cin >> a; v.push_back(a); } for (long long i = 0; 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 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 MOD = 1000000007; long long dp[2001][2001]; long long dp1[2001][2001]; int main() { int N, K; string S; cin >> N >> K >> S; memset(dp, 0, sizeof(dp)); memset(dp1, 0, sizeof(dp1)); dp[0][0] = dp1[0][0] = 1; for (int n = 1; n <=...
/* * 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; const long double PI = 3.14159265358979323846; const int MAXN = 1e5 + 3; long long n, a, b, p, q; bool isLeap(int a) { if (a % 400 == 0) return true; if (a % 4 == 0 && a % 100) return true; return false; } void solve() { int y; cin >> y; ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int ti = 0; ti < t; ti++) { int n, k; cin >> n >> k; vector<int> arr(n); for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr.begin(), arr.end()); vector<int> weights(k); for (int i ...
#include <bits/stdc++.h> using namespace std; const int INF = 2 * 1e9; const double EPS = 1e-9; const int MaxN = 100000 + 5; const int MaxM = 2 * 100000 + 5; int N, M, S, L, Dist[MaxN]; typedef struct Node { int idx; Node(void) {} Node(int _idx) { idx = _idx; } inline bool operator<(const ...
#include <bits/stdc++.h> using namespace std; void fff() { freopen( dravde.in , r , stdin); freopen( dravde.out , w , stdout); } const int MAXN = 100001; int n; map<int, int> m[MAXN]; int f[MAXN], s[MAXN], p[MAXN], cnt = 0, z; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; tuple<long long, long long, long long> arr[n - 1]; long long s1, e1; cin >> s1 >> e1; for (long long i = 0; i < n - 1; ++i) { long long s2, e2; cin >> s2 >> e2; arr[i] = make_tuple(e2 ...
/** * 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 in(char &c) { return scanf( %c , &c); } int in(char s[]) { return scanf( %s , s); } int in(int &x) { return scanf( %d , &x); } int in(long long &x) { return scanf( %lld , &x); } int in(double &x) { return scanf( %lf , &x); } int in(pair<int, int> &p) { ret...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const int nax = 1e6 + 10; long long fac[nax], ifac[nax], inv[nax]; long long ncr(int n, int k) { if (n < 0 || k < 0 || k > n) return 0; return fac[n] * ifac[k] % mod * ifac[n - k] % mod; } int main() { fac[0] = ifac...
#include <bits/stdc++.h> using namespace std; map<int64_t, int> mp1, mp2; int fnc(int n) { int ans = n + 1; for (auto i = mp1.begin(); i != mp1.end(); i++) { if (i->second >= (n + 1) / 2) return 0; if (i->second + mp2[i->first] >= ((n + 1) / 2)) ans = min(ans, (n + 1) / 2 - i->second);...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////////////////// // Company: Digilent Inc. // Engineer: Josh Sackos // // Create Date: 07/11/2012 // Module Name: PmodJSTK // Project Name: PmodJSTK_Demo // Target Devices: ICEStick // Tool versions: iCEcu...
/* * 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 mx = 1e9; struct Data { int p1, p2, p3, p4; Data(int a = mx, int b = mx, int c = mx, int d = mx) { p1 = a, p2 = b, p3 = c, p4 = d; } }; inline Data UN(Data a, Data b) { Data c; c.p1 = min(a.p1 + b.p1, a.p2 + b.p3), c.p2 = min(a....
module core( input iCLK, input [7:0] iGPI, output [7:0] oGPO ); wire [31:0] wIDATA; wire wWRDTA; wire wWRGPR; wire wWRSFR; wire wWRMLR; wire [1:0] wSGPRI; wire [2:0] wSAOUT; wire wUAZRO; wire ...
/** * 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 n; cin >> n; vector<int> a(n + 1); vector<int> b(n + 1); for (int i = 1; i <= n; i++) cin >> a[i]; sort(a.begin() + 1, a.end()); for (int i = 1; i <= n / 2; i++) b[2 * i] = a[i]; for (int i = n / 2 + 1; i <= n; i++) b[(i ...
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> string to_string(pair<A, B> p); template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p); string to_string(const string& s) { return + s + ; } string to_string(const char* s) { return to_string((...
#include <bits/stdc++.h> using namespace std; vector<int> primes; void sieve() { vector<bool> isComposite(100000000, false); for (int i = 2; i * i <= 100000000; i++) { if (isComposite[i] == false) for (int j = i * 2; j <= 100000000; j += i) isComposite[j] = true; } for (int i = 2; i ...
/* * PicoSoC - A simple example SoC using PicoRV32 * * Copyright (C) 2017 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...
// $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/verunilibs/data/unisims/IBUFDS_DIFF_OUT.v,v 1.10 2010/11/03 22:31:02 fphillip Exp $ /////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2004 Xilinx, Inc. // All Right Reserved. //////////////////////////////////////...
#include <bits/stdc++.h> using namespace std; int arr[4005]; int nxt[4005], prv[4005]; map<int, int> M; map<int, int> Q; int main() { int n; cin >> n; int ans = 0; for (int i = 0; i < n; ++i) { cin >> arr[i]; if (M.find(arr[i]) != M.end()) { nxt[M[arr[i]]] = i; pr...
#include <bits/stdc++.h> using namespace std; int n, w[200200], h[200200], W, a[200200], maxH, maxH2, id; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d%d , &w[i], &h[i]); if (h[i] > maxH) { maxH = h[i]; id = i; } W += w[i]; } for (in...
// Copyright 2012 Sriram Radhakrishnan, Varun Sampath, Shilpa Sarode // // This file is part of PVS. // // PVS 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 ...
#include <bits/stdc++.h> using namespace std; const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; bool ckmin(int& a, int b) { return b < a ? a = b, true : false; } bool ckmax(int& a, int b) { return b > a ? a = b, true : false; } const long long linf = 4000000000000000000LL; const long long inf = 100000...
////////////////////////////////////////////////////////////////////// //// //// //// uart_sync_flops.v //// //// //// //// ...
#include <bits/stdc++.h> using namespace std; const int maxn = 200200; int n, k; int a[maxn]; vector<int> g[maxn]; int sz[maxn]; int dpd[maxn], dpu[maxn]; int mxd[maxn], mxu[maxn]; int mark[maxn], cnt[maxn]; int mxc[maxn], N; int ans; void dfs(int v, int par = -1) { sz[v] = 1; cnt[v] = m...
#include <bits/stdc++.h> using namespace std; const int MM = 2e5 + 5; int n, k, a, b, q, pref[MM], suff[MM], cnt[MM]; void upd(int bit[], int x, int v) { for (; x < MM; x += x & -x) { bit[x] += v; } } int get(int bit[], int x) { int res = 0; for (; x > 0; x -= x & -x) res += bit[x]; ...
#include <bits/stdc++.h> using namespace std; using namespace std; vector<bool> Prime(20000000 + 1, 1); vector<bool> Pal(20000000 + 1, 1); void gen1() { long long int n = 2000000; Prime[1] = 0; for (long long int i = 2; i <= 20000000; i++) { if (Prime[i]) { for (long long int j = i +...
//############################################################################# //# Function: Padring Generator # //# Copyright: OH Project Authors. ALl rights Reserved. # //# License: MIT (see LICENSE file in OH repository) # ...
#include <bits/stdc++.h> using namespace std; long long n, m, vet[202020], cap[202020]; set<long long> s; int main() { scanf( %lld , &n); for (long long i = 1; i <= n; i++) scanf( %lld , &cap[i]), s.insert(i); scanf( %lld , &m); long long op, x, p, k; while (m--) { scanf( %lld , &op); ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:512000000 ) using namespace std; void solve(); void precalc(); clock_t start; int testNumber = 1; bool todo = true; int main() { start = clock(); int t = 1; cout.sync_with_stdio(0); cin.tie(0); precalc(); cout.precision(10)...
#include <bits/stdc++.h> using namespace std; int n, w; double tmp; vector<double> a; vector<double> boy; vector<double> girl; double volume; double base; int main() { cin >> n >> w; for (int i = 0; i < (2 * n); i++) { cin >> tmp; a.push_back(tmp); } sort(a.begin(), a.end()...
#include <bits/stdc++.h> int main() { int loop, cnt = 1, max = 1; scanf( %d , &loop); int arr[loop]; for (int i = 0; i < loop; i++) scanf( %d , &arr[i]); for (int i = 1; i < loop; i++) { if (arr[i - 1] >= arr[i]) { cnt = 1; } if (arr[i - 1] < arr[i]) { cnt++; ...
/* * 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; void solve() { int x, y, z; cin >> x >> y >> z; if (x > 0) { cout << 0 ; for (int i = 1; i <= x; i++) cout << 0 ; } if (y > 0) { if (x == 0) cout << 0 ; cout << 1 ; y--; } else if (z > 0 && y == 0 && x == 0) { ...
#include <bits/stdc++.h> using namespace std; string s; long cmpduong(string s1, string s2) { long len1 = s1.size(); long len2 = s2.size(); if (len1 < len2) return 2; if (len1 == len2) { if (s1 > s2) return 1; else return 2; } if (len1 > len2) return 1; } lo...
#include <bits/stdc++.h> using namespace std; vector<string> split(const string& s, const string& delim = ) { vector<string> res; string t; for (int i = 0; i != s.size(); i++) { if (delim.find(s[i]) != string::npos) { if (!t.empty()) { res.push_back(t); t = ; ...