text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int mpow(int base, int exp); void solve() { long long int n; cin >> n; vector<long long int> v(n); vector<long long int> cnt(2 * n + 1, 0); for (long long int i = 0; i < (n); i++) { cin >> v[i]; cnt[v[i]]++; } vector<long long i...
#include <bits/stdc++.h> using namespace std; const int maxn = 7, n = 7, maxm = 101; int m, cntblk = maxn, f[maxn], deg[maxn]; bool used[maxm]; class ed { public: int target, id; char type; ed(int t, int i, char ty) : target(t), id(i), type(ty){}; }; class ans { public: int id; c...
#include <bits/stdc++.h> using namespace std; struct node { int num; double w; } point[1005]; bool cmp(node a, node b) { if (fabs(a.w - b.w) < 0.0001) return a.num < b.num; return a.w > b.w; } int main() { int i, n, t1, t2, k, a, b; scanf( %d%d%d%d , &n, &t1, &t2, &k); for (i = 1...
#include <bits/stdc++.h> using namespace std; long long gi() { char cc = getchar(); long long cn = 0, flus = 1; while (cc < 0 || cc > 9 ) { if (cc == - ) flus = -flus; cc = getchar(); } while (cc >= 0 && cc <= 9 ) cn = cn * 10 + cc - 0 , cc = getchar(); return cn * flus; ...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:1000000000 ) static char s[1000][1000]; static int dp[2][505][505]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m, res = 0, d1, d2; cin >> n >> m; for (int i = 0; i < n; ++i) cin >> s[i]; dp...
#include <bits/stdc++.h> using namespace std; const int maxint = -1u >> 1; const double pi = 3.14159265358979323; const double eps = 1e-8; int n, k, a[100100]; set<long long> vis; int main() { scanf( %d%d , &n, &k); for (int i = (0); i < (n); i++) scanf( %d , &a[i]); sort(a, a + n); int an...
/*************************************************************************************************** ** fpga_nes/hw/src/cpu/apu/apu_envelope_generator.v * * Copyright (c) 2012, Brian Bennett * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are permitted * p...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int base = 1e9; const int MAX = 1e5; const double EPS = 1e-9; const double PI = acos(-1.); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, *a, *res, j = 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 "hrfp_defs.vh" // This module is not used anymore and may not function // correctly. This is kept here for historical reasons as I may want // to refer back to this module when implementing double precision // HRFP_16 numbers. module hrfp_normalize #(parameter PIPELINESTAGES=5) (input wire clk, inp...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 10; const long long int LINF = 1LL * INF * INF; const int MAXN = 2e5 + 10; const int MAXM = 5e3 + 10; priority_queue<int> pq; vector<vector<int> > graph; queue<int> que; long long int mygcd(long long int a, long long int b) { retu...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const long long inf = 1e18; const int maxn = 2e5 + 10; const double eps = 1e-7; const double pi = 3.14159265359; long long n, m, a[maxn], par[maxn]; bool check(int x) { long long now = 0; long long cnt = 0; long long cal ...
/** * 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...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2003 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (clk); input clk; reg [43:0] mi; reg [5:0] index; integer indexi; reg r...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; long long int inverse(long long int i) { if (i == 1) return 1; return (MOD - ((MOD / i) * inverse(MOD % i)) % MOD + MOD) % MOD; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; ci...
module testbench_CLA_Array(); localparam bits = 64; reg[bits-1:0] a; reg[bits-1:0] b; reg cin; wire[bits-1:0] result; wire cout; wire[bits:0] expectOutput; reg errorFlag = 0; integer i; assign expectOutput = a + b + cin; initial begin a = 64'h1111111111111111; b = 64'hffffffffffffffff; cin = 1; #10...
/* * Copyright 2017 Google Inc. * * 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 to...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016 // Date : Tue Sep 26 16:58:56 2017 // Host : vldmr-PC running 64-bit Service Pack 1 ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2006 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc=0; reg [63:0] crc; integer i; reg [63:0] mem [7:0]; ...
#include <bits/stdc++.h> using namespace std; double r, L; double b, u, A; double x, y, a; double D[95], B[95]; struct st { double x, y, a; }; st bear[50]; int t; double fun(int i, double l) { x = bear[i].x; y = bear[i].y; t = bear[i].a; a = B[t]; b = (fabs(l - x) / y); A...
// 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 Apr 09 08:27:07 2017 // Host : GILAMONSTER running 64-bit major release (...
/* * 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; template <typename T> void print(const T& t) { cout << t << n ; } template <typename T, typename U, typename... ARGS> void print(const T& t, const U& u, const ARGS&... args) { cout << t << ; print(u, args...); } signed main() { ios_base:...
module reg_ro_4burst( input wire clk, input wire [15:0] bus_ad, // raw mux data input wire [18:0] my_a, input wire [2:0] bus_a, // high address bits input wire adv, // active high, so connect to !EIM_LBA input wire rw, // low = write, high = read, so connect to EIM_RW ...
#include <bits/stdc++.h> using namespace std; map<int, int> cnt; int n; int m; int dp[500][100005]; vector<int> num; map<int, int> can; int ind = 0; int dpnum[500]; map<int, int> mpind; map<int, int> mpvis; int main() { scanf( %d%d , &n, &m); int x; for (int i = 0; i < n; i++) { ...
// (c) Copyright 1995-2017 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 license and does not grant ...
#include <bits/stdc++.h> using namespace std; const int maxn = 205; int mat[maxn][maxn], tmp[maxn][maxn]; int r[maxn], c[maxn]; int n, m; void invRow(int row) { for (int j = 1; j <= m; ++j) { tmp[row][j] ^= 1; } } void invCol(int col) { for (int i = 1; i <= n; ++i) { tmp[i][col] ...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); vector<long long> X(n + 1), Y(n + 1); for (int i = (1); i <= (n); ++i) scanf( %lld%lld , &X[i], &Y[i]); long long S = 0; for (int k = (1); k <= (n); ++k) { vector<double> V; for (int i = (1); i <= ...
#include <bits/stdc++.h> using namespace std; int n, b; int t[200005], d[200005]; queue<pair<int, pair<int, int> > > Q; long long ans[200005]; int main() { int i, j; scanf( %d , &n); scanf( %d , &b); for (i = 1; i <= n; i++) { scanf( %d , &t[i]); scanf( %d , &d[i]); } mem...
//----------------------------------------------------------------------------- //-- (c) Copyright 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 propert...
#include <bits/stdc++.h> using namespace std; const int N = 111; int a[N], b[N]; int main() { cin.tie(0)->sync_with_stdio(0); int t; cin >> t; while (t--) { queue<int> que; int n; cin >> n; string S; cin >> S; S = + S; for (int i = 1; i <= n; i++) { ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable 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; int n, x, y, u, v, to[600005], nxt[600005], p[300005], sz[300005]; void dfs(int x, int lst) { sz[x] = 1; for (int i = p[x]; i != -1; i = nxt[i]) if (to[i] != lst) { dfs(to[i], x); sz[x] += sz[to[i]]; } } int main() { scanf( ...
#include <bits/stdc++.h> using namespace std; double res, a, b; int main() { int n, k; cin >> n >> k; vector<double> x(n), y(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; if (i) { a = x[i] - x[i - 1]; b = y[i] - y[i - 1]; res += sqrt((a * a) + (b * 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 law...
//This is a 3-stage integer pipeline. //It fetches dependencies, executes, and writes back to a register file. module intpipe( CLK, PAUSE, EMPTY, OPCODE, A, B, C, ADAT, BDAT, FLGS, aSel, bSel, cSel, cOut, cWrite, flgs ); input CLK; input PAUSE; input EMPTY; input [3:0] OPCODE; input...
/////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2014 Francis Bruno, All Rights Reserved // // 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...
#include <bits/stdc++.h> using namespace std; int p[400050]; int ran[400050]; int find_set(int a) { return p[a] == a ? a : (p[a] = find_set(p[a])); } int unite(int a, int b) { int x = find_set(a); int y = find_set(b); if (x == y) return -1; if (ran[x] < ran[y]) { p[x] = y; } else { ...
`include "lo_read.v" /* pck0 - input main 24MHz clock (PLL / 4) [7:0] adc_d - input data from A/D converter lo_is_125khz - input freq selector (1=125kHz, 0=136kHz) pwr_lo - output to coil drivers (ssp_clk / 8) adc_clk - output A/D clock signal ssp_frame ...
#include <bits/stdc++.h> using namespace std; int tree[500005 << 2]; struct P { int x, y, z; int id; } p[500005]; bool cmp1(P a, P b) { if (a.x != b.x) return a.x > b.x; else if (a.y != b.y) return a.y > b.y; else return a.z > b.z; } bool cmp2(P a, P b) { return a.y <...
#include <bits/stdc++.h> using namespace std; int n, d; int main() { cin >> n >> d; int m; cin >> m; for (int i = 1; i <= m; i++) { int x, y; cin >> x >> y; puts((d <= x + y && x + y <= 2 * n - d && -d <= x - y && x - y <= d) ? YES : NO ); } ...
#include <bits/stdc++.h> using namespace std; bool cmp(const pair<int, pair<int, int>> a, const pair<int, pair<int, int>> b) { if (a.first == b.first) { return a.second.first > b.second.first; } else { return a.first < b.first; } } int main() { ios_base::sync_with_stdio(false); i...
#include <bits/stdc++.h> using namespace std; const int inf = 0x20202020; const int mod = 1000000007; inline void read(int &x) { char ch; bool f = 0; int a = 0; while (!((((ch = getchar()) >= 0 ) && (ch <= 9 )) || (ch == - ))) ; if (ch != - ) a *= 10, a += ch - 0 ; else ...
#include <bits/stdc++.h> using namespace std; long long int fact(long long int n) { long long int ans = 1; for (long long int i = 2; i <= n; i++) ans = (ans % 1000000007 * i % 1000000007) % 1000000007; return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); 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...
// *************************************************************************** // *************************************************************************** // Copyright 2011(c) Analog Devices, Inc. // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // a...
/******************************************************************************* * 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 ...
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int N = 100005; const double PI = 4 * atan(1); const double eps = 1e-7; const long long oo = 1e10; const int K = 26; vector<int> sort_cyclic_shifts(string const& s) { int n = s.size(); const int alphabet = 256; ...
// // Take a 32 bit number in and distribute it's bits over a 1024 bit output bus // in some randomish pattern. // `include "timescale.vh" module shuff ( input wire [62 : 0] x, output wire [32*16 - 1 : 0] out ); assign out = { {!x[00], x[62],!x[02], x[28],!x[09], x[55], x[03],!x[34], x[45], x[...
// // Copyright 2011 Ettus Research LLC // // 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 // (at your option) any later version. // // This program is dis...
//----------------------------------------------------------------------------- // // (c) Copyright 2010-2011 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; const double PI = acos(-1.0); const double EPS = 1e-7; const long long BIG_PRIME7 = 1000000007; const long long BIG_PRIME9 = 1000000009; int gcd(int x, int y) { return y ? gcd(y, x % y) : x; } char ch = a ; int j, n, m, L, i; int N, C; int x, y, z, k; ...
#include <bits/stdc++.h> using namespace std; const int N = 505; char g[N][N]; int id[N][N]; int cnt = 1; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int amt[N * N]; int sz[N * N]; int sum; int n, k; void dfs(int i, int j, int idx) { if (g[i][j] == X or id[i][j]) return; id[i][...
/* Copyright (c) 2014 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, distribute,...
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } const int MAXN = 1e5 + 1e4; int n, pos_ = 0; vector<int> g[MAXN]; vector<int> a[MAXN]; vector<int> ans; vector<vector<int>> t(4 * MAXN); vector<int> parent(MAXN), depth(MA...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool uin(T& a, T b) { return a > b ? (a = b, true) : false; } template <class T> inline bool uax(T& a, T b) { return a < b ? (a = b, true) : false; } int main() { ios::sync_with_stdio(false); cin.tie(0); string s...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:66777216 ) using namespace std; const int N = 1001002; int a, b, c, d, i, j, n, m, k, tot, now, last; int nx[N][26], sib[N], pr[N], fir[N]; int cnt[N], en[N]; char str[502]; int num[2][N]; int dp[2][2002][2002]; vector<int> lev[503]; int dfs...
#include <bits/stdc++.h> #pragma GCC optimize( O3 , unroll-loops ) #pragma GCC target( avx2 ) using namespace std; const int maxn = 1e6 + 5; int n; bool used[maxn]; vector<int> v[maxn]; vector<int> g[maxn]; int ans[maxn]; int pr[maxn]; int t[4 * maxn]; void init() { used[0] = true; used...
#include <bits/stdc++.h> using namespace std; int m, n; int main() { cin >> n >> m; if (n == 1) { cout << 1; return 0; } if (m <= n - m) { cout << m + 1; return 0; } cout << m - 1; }
#include <bits/stdc++.h> using namespace std; const int L = 500; const int N = 220000; const int M1 = 1e9 + 7; const int M2 = 1e9 + 9; int chd[N][26], go[N][26]; int len[N], q[N], p[N]; int s[N], dp[N], f[17][N], t[N]; char str[N], _str[N]; int st[N], en[N], wh[N], fr[N], to[N], cur[N], state[N], id...
/** * 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 = 1e5 + 5; const long long INF = 1e18; const long long LIMIT = 1500000LL * 1500000LL; vector<int> V; int ans[MAXN]; struct node { long long x, y, pos; long long dis() { return x * x + y * y; } }; node p[MAXN]; bool cmp(node A, node...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const long long p = 1e9 + 7; int par[MAXN][2], size[MAXN][2], dist[MAXN][2], val[MAXN][2]; int groups, n, k; pair<int, int> find(int e, int x) { if (par[x][e] == x) { return pair<int, int>(x, 0); } pair<int, int> t = f...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int N = (int)2e6 + 5; int n, q, a[N], l[N], r[N]; int main() { for (scanf( %d , &q); q--;) { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , a + i); for (int i = 1; i <= n; ++i) l[i] = n + 1, r[i] = -1...
//////////////////////////////////////////////////////////////////////////////// // Original Author: Schuyler Eldridge // Contact Point: Schuyler Eldridge () // div_pipelined.v // Created: 4.3.2012 // Modified: 4.5.2012 // // Testbench for div_pipelined.v // // Copyright (C) 2012 Schuyler Eldridge, Boston University //...
/* Copyright 2018 Nuclei System Technology, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 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 = 400 + 5; const int INF = 1e9; int R, n, m; pair<int, int> H[N], T[N]; int vis[N][N]; vector<pair<int, int> > adj[N][N]; queue<pair<int, int> > Q; int dis[N][N]; int bfs(int h, int t) { memset(dis, 0x3c, sizeof dis); dis[h][t] = 0; ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 00:14:30 03/29/2014 // Design Name: regfile // Module Name: D:/XilinxProject/CPU/regfile_test.v // Project Name: CPU // Target Device: // Tool versions: // Descr...
/** * 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...
// ********************************************************************/ // Actel Corporation Proprietary and Confidential // Copyright 2010 Actel Corporation. All rights reserved. // // ANY USE OR REDISTRIBUTION IN PART OR IN WHOLE MUST BE HANDLED IN // ACCORDANCE WITH THE ACTEL LICENSE AGREEMENT AND MUST BE APPROVED...
#include <bits/stdc++.h> using namespace std; #pragma GCC target( avx2 ) #pragma GCC optimization( unroll-loops ) #pragma GCC optimize( O2 ) constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1}; constexpr long long INF = 1999999999999999997; constexpr int in...
`include "core.h" `default_nettype none module decode_mmucheck( input wire iPAGING_ENA, input wire iKERNEL_ACCESS, input wire [13:0] iMMU_FLAGS, output wire [2:0] oIRQ40, output wire [2:0] oIRQ41, output wire [2:0] oIRQ42 ); /************************************************* MMU Flag Check [0] :...
#include <bits/stdc++.h> using namespace std; template <class T, class L> bool smax(T& x, L y) { return x < y ? (x = y, 1) : 0; } template <class T, class L> bool smin(T& x, L y) { return x > y ? (x = y, 1) : 0; } const int maxn = 2e5 + 17, mod = 1e9 + 7; struct Seg { int lazy[maxn << 2], ...
`include "senior_defines.vh" `include "mnemonics.h" `include "registers.h" module instruction_decoder #(parameter spr_adr_w = `SPR_ADR_BUS_WIDTH) ( input wire clk_i, input wire reset_i, input wire [31:0] pm_inst_bus_i, output wire [`AGU_CTRL_WIDTH-1:0] agu_ctrl_o, ou...
// niosii_nios2_gen2_0.v // This file was auto-generated from altera_nios2_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.1 185 `timescale 1 ps / 1 ps module niosii_nios2_gen2_0 ( input wire clk, // ...
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; int t = 0; while (str[t]) { if (str[t] == . ) { cout << 0; t++; } else if (str[t] == - && str[t + 1] == . ) { cout << 1; t += 2; } else if (str[t] == - && str[t ...
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin...
#include <bits/stdc++.h> using namespace std; const int maxn = 5005; int u[maxn], v[maxn], w[maxn], dp[maxn][maxn], parent[maxn][maxn], x[maxn]; int main() { int n, m, t, pos; cin >> n >> m >> t; for (int i = 0; i < m; i++) { cin >> u[i] >> v[i] >> w[i]; } memset(dp, 0x3f, sizeof(dp));...
#include <bits/stdc++.h> using namespace std; static const int maxn = 100012; int K1, K2, K3; int T1, T2, T3; int N; int C[maxn]; void Read() { int i; scanf( %d%d%d , &K1, &K2, &K3); scanf( %d%d%d , &T1, &T2, &T3); scanf( %d , &N); for (i = 0; i < N; ++i) { scanf( %d , &C[i]); ...
#include <bits/stdc++.h> long long t, a, b, h, f[110]; using namespace std; long long mi(long long n, long long m) { long long res = 1; for (int i = 1; i <= m; i++) res *= n; return res; } void solve(long long a, long long b) { for (int i = h; i; i--) { long long t = mi(a, i); f[i]...
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>; const ll inf = 1LL << 60; vector<ll> dv; void divisor(ll n) { for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { if (i == n / i)...
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { x = 0; char c = getchar(); bool flag = false; while (!isdigit(c)) { if (c == - ) flag = true; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = ...
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) const int N = 2e5 + 5, L = 19; string s; int cl[L][N], sf[L][N], ct[N], pos[N], lcp[N], t[L][N], g[N]; pair<int, int> a[N + N]; int *suf = sf[L - 1]; int que(int l, int r) { int k = g[r - l + 1]; return min(t[k][l], t[...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int main() { int n; cin >> n; int maxn = 0; int x, y; while (n--) { scanf( %d %d , &x, &y); maxn = max(maxn, x + y); } cout << maxn << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> arr(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } int m; cin >> m; while (m--) { int k, pos; cin >> k >> pos; pos--; vector<vector<int>> ans(k); vector<lon...
#include <bits/stdc++.h> #pragma optimize( avx ) #pragma optimize( no-stack-protector ) namespace io { inline char gnc() { return (char)getchar(); } template <typename T> inline void gi(T &dx) { dx = 0; int yc = gnc(); bool nega = false; while (yc < 0 || yc > 9 ) { nega = (yc == - ...
#include <bits/stdc++.h> const int INF = 2147483647; using namespace std; unsigned char like[7][7]; int fenzu[7]; int n, totjy[3]; int getnum(char l[50]) { switch (l[0]) { case A : return 0; case C : if (l[1] == h ) return 1; else return 2; ...
#include <bits/stdc++.h> using namespace std; int a[100000], b[100000], c[100000][2]; int n, m; long long k, sum; int main() { cin >> n >> k; sum = 0; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); b[i] = a[i]; long long aa = a[i]; sum += aa; } if (sum <= k) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n; long long d; cin >> n >> d; vector<long long> v; long long x; for (int i = 0; i < n; i++) { cin >> x; v.push_back(x); } int count = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++)...
#include <bits/stdc++.h> struct f { int pos; int num; } a[108]; int cmp(const void *a, const void *b) { return (*(struct f *)a).num - (*(struct f *)b).num; } int main() { int n, k; while (scanf( %d%d , &n, &k) == 2) { int i; for (i = 0; i < n; i++) { scanf( %d , &a[i].n...
#include <bits/stdc++.h> using namespace std; long long ans, p, s; int N; struct node { int a[2]; node *L, *R; node() { a[0] = a[1] = 0; L = R = NULL; } void add() { if (L == NULL) L = new node(); if (R == NULL) R = new node(); } }; void update(node *no, long ...
/* Copyright (c) 2014-2018 Alex Forencich Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distri...
#include <bits/stdc++.h> using namespace std; const long long N = 4e5 + 5; pair<long long, long long> arr[N]; long long l[N]; long long s[N]; long long dp[N]; long long bit[N]; long long n; void update(long long idx, long long val) { while (idx <= n) { bit[idx] = max(bit[idx], val); id...
//====================================================================== // // coretest_bp_entropy.v // --------------------- // Top level module for the BP FPGA entropy source tester. // // // Author: Joachim Strombergson // Copyright (c) 2014 Secworks Sweden AB // All rights reserved. // // Redistribution and use 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; bool compare(pair<int, int> a, pair<int, int> b) { return a.first < b.first; } int main() { float r1, r2, c1, c2, d1, d2; cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2; float a = c1 / 2 + (d1 + r1 - d2 - r2) / 4; float c = c1 / 2 - (d1 + r1 - d2 - r2) / 4; ...