text
stringlengths
59
71.4k
module ADT7310P16S16 ( (* intersynth_port="Reset_n_i" *) input Reset_n_i, (* intersynth_port="Clk_i" *) input Clk_i, (* intersynth_port="ReconfModuleIn_s", intersynth_conntype="Bit" *) input Enable_i, (* intersynth_port="ReconfModuleIRQs_s", intersynth_conntype="Bit" *) output CpuIntr_o, (* inters...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, s, i, j; cin >> n >> m >> s; long long ans = 0; for (i = 1; i <= n; i += 2) { for (j = 1; j <= m; j += 2) { long long cnt = (n - i + 1) * (m - j + 1); long long tmp = 0; if (i * j == s) { tmp...
//---------------------------------------------------------------------------- //-- echo.v: Uart-rx example 2 //-- All the received characters are echoed //---------------------------------------------------------------------------- //-- (C) BQ. December 2015. Written by Juan Gonzalez (Obijuan) //-- GPL license //-----...
#include <bits/stdc++.h> using namespace std; const long long p = 1e9 + 7; const long double pi = 3.1415926535898; int main() { int s, n; cin >> s >> n; vector<pair<int, int> > a(n); for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second; sort(a.begin(), a.end()); for (int i = 0; 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 1ns/100ps module FunctionalTest; reg clk_50mhz; reg clk_1mhz; reg rst_x; reg r_init; reg ...
module paddle_control( input clock, reset, enable, rotary_event, rotary_right, input [4:0] speed, input [5:0] radius, input middle, output reg [9:0] paddle_x, paddle_y ); localparam PD_H = 8; localparam MAXX = 320; localparam MAXY = 480; localparam LEFT = 160; localparam TOP = 0; reg [9:0] next_x, next_y; alway...
#include <bits/stdc++.h> using namespace std; long long k, ans, a[501], i, g, n; long long check(long long x) { k = 0; if (x == 1) return 0; for (long long i = 1; i <= n; i++) if (a[i] / (x - 1) * x < a[i]) return 0; else k += (a[i] + x - 1) / x; if (k < ans) ans = k; ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 08:25:00 02/19/2014 // Design Name: // Module Name: display4digit // Project Name: // Target Devices: // Tool versions: // Description: // // D...
#include <bits/stdc++.h> using namespace std; int cnt1 = 0; const int maxn = 1e5; int fac[maxn + 5], vis[maxn + 5]; vector<int> prime; void init() { memset(vis, 0, sizeof(vis)); for (int i = 2; i <= maxn; i++) { if (!vis[i]) prime.push_back(i); for (int j = 0; j < prime.size() && i * pri...
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long a, b; cin >> a >> b; long long xx = fabs(a - b); long long d = xx / 2; if ((a + b) % 2) { long long yy = a + b - 2 * d + 1; cout << yy << n ; ...
// *************************************************************************** // *************************************************************************** // Copyright 2013(c) Analog Devices, Inc. // Author: Lars-Peter Clausen <> // // All rights reserved. // // Redistribution and use in source and binary forms, ...
#include <bits/stdc++.h> using namespace std; const int maxn = 310; int g[maxn][maxn]; int best[maxn]; int a[maxn]; int ans[maxn]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int v; scanf( %d , &v); g[i][v] = ...
#include <bits/stdc++.h> using namespace std; const int N = 1000007; int v[N]; vector<int> pos[N]; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> v[i]; pos[v[i]].push_back(i); } for (int i = 0; i < N; ++i) { reverse(pos[i].begin(), pos[i].end()); }...
#include <bits/stdc++.h> using namespace std; const int MAX = 1 << 20, KOR = 32000; const long long INF = 1e18; int n; int p[MAX]; int sito[KOR]; int bezp[MAX], sp[MAX]; int cijseg, cijprom; vector<int> Pr; void Eratosten() { for (int i = 2; i < KOR; i++) { if (!sito[i]) { Pr.push_...
#include <bits/stdc++.h> using namespace std; const int N = (int)1e3 + 10; int n; pair<string, int> a[N]; string ans[N]; int main() { cin >> n; for (int i = 0; i < n; ++i) { char c; cin >> c >> c >> c >> c; cin >> a[i].first; a[i].second = i; if (a[i].first == 9 ) ans[...
// ============================================================== // RTL generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC // Version: 2017.1 // Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved. // // =========================================================== `timescale 1 ns / 1 ps ...
/////////////////////////////////////////////////////////////////////////////// // // 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 Found...
#include <bits/stdc++.h> using namespace std; const long long N = 100000; const long long inf = (long long)1e9; const long long MOD = (long long)1e9 + 7; const long double eps = 1e-6; const long long ABC = 26; const long long P = 239; int main() { ios_base::sync_with_stdio(0); cin.tie(0); co...
#include<bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false), cin.tie(nullptr); int _; for (cin >> _; _--;) { int n; cin >> n; int a[n + 1]; int cnt = 0; for (int i = 1; i <= n; ++i) { cin >> a[i]; if (a[i] != i)cnt++; } ...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, k; cin >> n >> k; string s; cin >> s; long long x = -1; for (long long i = 97; i <= 122; ++i) { char c = char(i); long long cnt = 0; for (long...
#include <bits/stdc++.h> using namespace std; int a[107], b[107]; int main() { int m, s; cin >> m >> s; int ss = s; if (s >= 2 and s <= m * 9) { s--; a[m] = 1; for (int i = 1; i <= m; i++) { if (s > 9) { a[i] += 9; s -= 9; } else { 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...
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 7; int arr[200005]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; if (n % 2 == 0) { cout << NO n ; return 0; } int flag = 1, ct = 1; for (int i = 1; i <= n;...
#include <bits/stdc++.h> using namespace std; int i, n, l, miao, lala; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; cin.ignore(); while (n--) { char s[105]; miao = 0; lala = 0; cin.getline(s, 105); int l = strlen(s); if (l > 4 && s[0]...
#include <bits/stdc++.h> using namespace std; struct tp { int l, r; }; int n; vector<tp> t; bool comp(tp a, tp b) { return a.l < b.l or a.l == b.l and a.r < b.r; } int main() { cout.sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) { int l, r; cin >> l >> 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...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i; cin >> n; string s; cin >> s; map<char, long long int> a; if (n > 26) { cout << -1 << endl; return 0; } long long int ans = 0; for (i = 0; i < n; i++) { if (a[s[i]] >= 1) ans++; ...
#include <bits/stdc++.h> using namespace std; int n; vector<int> vans; set<int> s; int main() { scanf( %d , &n); int start = 1; for (int i = 1; i <= n; ++i) { int x; scanf( %d , &x); if (s.count(x)) { vans.push_back(start); vans.push_back(i); start = i + 1...
#include <bits/stdc++.h> using namespace std; void Solves(); void In(int **a, int n); int main() { Solves(); return 0; } void Solves() { long long n, k; cin >> n >> k; if (k > n * n) { cout << -1; return; } int **a = new int *[n + 1]; for (int i = 0; i <= n; i++) ...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009, 2010 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 distribut...
#include <bits/stdc++.h> using namespace std; const long long int mxn = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t = 1; cin >> t; while (t--) { long long int i, j, k, n, m; string s; cin >> s; n = s.length(); string a, b, c; ...
`timescale 1ns / 1ps /*********************************************************************** This file is part of the OpenADC Project. See www.newae.com for more details, or the codebase at http://www.assembla.com/spaces/openadc . This file is the serial interface. It can be replaced with a variety of other interface...
// ========== Copyright Header Begin ========================================== // // OpenSPARC T1 Processor File: pcx_dp_macc_r.v // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. // // The above named program is free software; you can redistribute it and...
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { long long ans = 1; while (b > 0) { if (b % 2 != 0) { ans = (ans * a) % 1000000007; } a = ((a % 1000000007) * (a % 1000000007)) % 1000000007; b >>= 1; } return ans; } void sie...
(** * ImpCEvalFun: Evaluation Function for Imp *) (* $Date: 2012-02-22 04:00:00 -0500 (Wed, 22 Feb 2012) $ *) (* #################################### *) (** ** Evaluation Function *) Require Import Imp. (** Here's a first try at an evaluation function for commands, omitting [WHILE]. *) Fixpoint ceval_step1 (st...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; long long g = n - 1, res = 0; while (g > 0 && k > 0) { res += g * 2 - 1; k--; g -= 2; } cout << res; return 0; }
#include <bits/stdc++.h> #pragma GCC optimize( Ofast , unroll-loops ) using namespace std; const int inf = numeric_limits<int>::max() / 2; const long double eps = 1e-9; const long double pi = acos(-1); const int MAXN = (3e8 + 10) / 3; int n; unsigned int a, b, c, d; bitset<MAXN> primes; unsigned in...
#include <bits/stdc++.h> using namespace std; map<long long, int> last; int b[1000000]; long long a[100000]; long long d[100][2]; pair<long long, long long> solve(long long x, long long y) { long long xx, yy; pair<long long, long long> ans; if (x == 1) { return make_pair(1, 0); } x...
#include <bits/stdc++.h> using namespace std; long long cas; long long a; long long b; long long c; long long d[] = {0, 1, -1}; int main() { scanf( %lld , &cas); while (cas--) { scanf( %lld %lld %lld , &a, &b, &c); long long ans = 21413524368453; for (long long i = 0; i < 3; ++i)...
#include <bits/stdc++.h> long long ans, fac[101000], fac_inv[101000], sum, nn; int n, k, len; char s[101000]; inline long long C(int x, int y) { if (x < y || x < 0 || y < 0) return 0; if (y == 0) return 1; return fac[x] * fac_inv[y] % 1000000007 * fac_inv[x - y] % 1000000007; } inline long long ...
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; } template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } ...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> static inline void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> static inline void amax(T &x, U y) { if (x < y) x = y; } template <typename T> static inline void sd(vector<T> &x) { so...
/** * 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 written by Zhiyang Ong * and Andrew Mattheisen * for EE577b Troy WideWord Processor Project */ `timescale 1ns/10ps /** * `timescale time_unit base / precision base * * -Specifies the time units and precision for delays: * -time_unit is the amount of time a delay of 1 represents. * The time uni...
#include <bits/stdc++.h> using namespace std; int main() { int h1, m1, h2, m2, result1, result2; char c = : ; while (cin >> h1 >> c >> m1 >> h2 >> c >> m2) { if (m1 < m2) { h1 -= 1; m1 += 60; } result2 = m1 - m2; result1 = h1 - h2; if (result1 < 0) result1 ...
module sd_ctrl(reset, clock, sd_in, sd_out, emmit_command, command_timeout, response_ready, serialize_complete, deserialize_complete, enable_serializer, enable_deserializer, reset_serializer, big_response, frame_deserializer ); i...
#include <bits/stdc++.h> using namespace std; template <typename T> struct fenwick_tree { int tree_n = 0; T tree_sum = 0; vector<T> tree; fenwick_tree(int n = -1) { if (n >= 0) init(n); } void init(int n) { tree_n = n; tree_sum = 0; tree.assign(tree_n + 1, 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> using namespace std; const int N = (int)1e6 + 1; const int INF = (int)1e9; const int logN = 20; int n, k, a[N], Log2[N]; int maxValue[N][21]; int getMax(int l, int r) { int k = Log2[r - l + 1]; return max(maxValue[l][k], maxValue[r - (1 << k) + 1][k]); } void solve() {...
#include <bits/stdc++.h> using namespace std; vector<pair<int, pair<int, int> > > v; int x; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int arr[500001]; int tree[500001 * 5]; void init(int node, int b, int e) { if (b == e) { tree[node] = arr[b]; return; ...
/* Copyright (c) 2016 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,...
// 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 : Thu May 25 15:28:04 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimize( O3 ) bool FLAG = 0; using namespace std; const long long MOD = (long long)1e9 + 7, N = (long long)2e6 + 222; const long long INF = (long long)1e18; long long dx[] = {0, -1, 0, 1, 0}; long long dy[] = {0, 0, 1, 0, -1}; long long ...
#include <bits/stdc++.h> using namespace std; const int N = 1000010; int n, ans[N], cnt = 1; vector<int> id[N], cur[N]; vector<int> g[N]; bool vis[N], done[N]; int sz[N], ns[N], ns2[N], comp_cnt, comp[N], allns = 0; void DFS(int node) { sz[comp_cnt]++; vis[node] = true; comp[node] = comp_cnt...
#include <bits/stdc++.h> const int N = 100100; struct Edge { int weight, type; int x, y; int num; bool operator<(const Edge& other) const { return weight == other.weight ? type > other.type : weight < other.weight; } } edges[N]; int n, m; int x[N], y[N]; bool b[N]; int main() { ...
#include <bits/stdc++.h> using namespace std; int MOD = 1e9 + 7; long long int power(long long int a, long long int b) { long long int res = 1; a = a % MOD; while (b > 0) { if (b & 1) { res = (res * a) % MOD; b--; } a = (a * a) % MOD; b >>= 1; } return r...
#include <bits/stdc++.h> int main() { char s[50]; scanf( %s , s); int i, l = strlen(s), flag = 0; for (i = 0; i < l; i++) { if (s[i] != s[l - i - 1]) flag++; } if (flag == 2) printf( YES ); else if (flag == 0 && strlen(s) % 2 == 1) printf( YES ); else printf( NO...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; int d[100005]; int pr[100005]; int cnt[100005]; int a[100005]; vector<int> g[100005]; int b[100005]; int main() { int n, i, j; scanf( %d , &n); for (i = 1; i <= n; ++i) { scanf( %d , &a[i]); ...
// (c) Copyright 1995-2016 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 ...
/** * 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...
module glbl (); parameter ROC_WIDTH = 1000; parameter TOC_WIDTH = 0; wire GSR; wire GTS; wire PRLD; reg GSR_int; reg GTS_int; reg PRLD_int; //-------- JTAG Globals -------------- wire JTAG_TDO_GLBL; wire JTAG_TCK_GLBL; wire JTAG_TDI_GLBL; wire JTAG_TMS_GLBL; wir...
/** * 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 code is generated by Terasic System Builder //======================================================= module CPC2_DE10( //////////// CLOCK ////////// input FPGA_CLK1_50, input FPGA_CLK2_50, input ...
////////////////////////////////////////////////////////////////////// //// //// //// Generic Single-Port Synchronous RAM //// //// //// //// This file is part of memory li...
//deps: control.v `include "cpu_constants.vh" module control_tb; // Beginning of automatic reg inputs (for undeclared instantiated-module inputs) reg clk; // To uut of control.v reg en; // To uut of control.v reg en_mem; // To uut of control.v reg imm; // To uut of control.v reg mem_wait; // To uut o...
module top; reg pass; wire [1:0] out; reg [1:0] drive_val; reg [1:0] oe_n; reg [2:0] pull_vec; bufif0 bufs[1:0] (out, drive_val, oe_n); assign (pull0, pull1) out = pull_vec[1:0]; initial begin pass = 1'b1; pull_vec = 3'b000; oe_n = 2'b00; // Drive is selected. drive_val = ...
#include <bits/stdc++.h> using namespace std; const int inf = 0x7f7f7f7f; int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; vector<int> arr; int main() { int n; string st; int x; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &x); arr...
/**************************************************************************************************/ /* Many-core processor project Arch Lab. TOKYO TECH */ /**************************************************************************************************/ `default_nettype ...
#include <bits/stdc++.h> using namespace std; const int Imx = 2147483647; const long long Lbig = 2e18; const int mod = 1e9 + 7; struct fastio { char s[100000]; int it, len; fastio() { it = len = 0; } inline char get() { if (it < len) return s[it++]; it = 0; len = fread(s, 1, ...
#include <bits/stdc++.h> using namespace std; const int mod = int(1e9) + 7; const int MX = 200500; long long f[MX]; long long f1[MX]; int pow_mod(long long a, int st) { a %= mod; long long res = 1; while (st) { if (st & 1) { res *= a; res %= mod; } a *= a; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, l; cin >> n >> l; deque<int> v; while (n--) { int m; cin >> m; v.push_back(m); } sort(v.begin(), v.end()); int a = v[0]; int b = v[v.size() - 1]; v.push_front(a * (-1)); v.push_back(2 * l - b)...
#include <bits/stdc++.h> using namespace std; const double pi = 3.1415926535897932384626433832795; const int inf = 1e9; const long long inf2 = 1e18; const int mod = 1e9 + 7; void boost() { ios_base::sync_with_stdio(false); cin.tie(NULL); } inline long long exp(long long x, long long n, long long...
#include <bits/stdc++.h> using namespace std; int n, a[6], t; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &t), a[t]++; } if (a[0] == 0) { printf( -1 n ); return 0; } int k = a[5] / 9; for (int i = 0; i < k; i++) { printf( 555555555 );...
/** * Embedded Systems (EECE6017C) - Lab 3 * Simple Processor * Author(s): Alex Stephens <> (AWS) * Josh Boroff <> (JBB) * Adam Wilford <> (AFW) * Target FPGA: Altera Cyclone II 2C20 (EP2C20F484C7) * Tool: Quartus II 64-bit * Version: 13.0.1 sp1 * */ /** * Module counter - Thi...
//***************************************************************************** // (c) Copyright 2008-2009 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 // ...
`timescale 1ns/10ps module pixel_pll_0002( // interface 'refclk' input wire refclk, // interface 'reset' input wire rst, // interface 'outclk0' output wire outclk_0, // interface 'locked' output wire locked ); altera_pll #( .fractional_vco_multiplier("false"), .reference_clock_frequency("50.0 MHz"), ...
#include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); int x = s.length(); x = (x + 1) * 26 - x; printf( %d , x); return 0; }
// /** // * This Verilog HDL file is used for simulation and synthesis in // * the chaining DMA design example. It contains the descriptor header // * table registers which get programmed by the software application. // */ // synthesis translate_off `include "altpcierd_dma_dt_cst_sim.v" `timescale 1ns / 1ps // synt...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 02/20/2015 01:01:21 PM // Design Name: // Module Name: marker_tracker // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: //...
// // dspmem.v -- display memory // module dspmem(rdwr_row, rdwr_col, wr_data, rd_data, en, wr, clk, pixclk, txtrow, txtcol, attcode, chrcode, chrrow_in, chrcol_in, blank_in, hsync_in, vsync_in, blink_in, chrrow_out, chrcol_out, blank_out, ...
#include <bits/stdc++.h> int main() { int n, m, sum = 0, i, j; int a[500][3], b[500][3]; scanf( %d , &n); for (i = 0; i < n; i++) scanf( %d %d %d , &a[i][0], &a[i][1], &a[i][2]); scanf( %d , &m); for (i = 0; i < m; i++) scanf( %d %d %d , &b[i][0], &b[i][1], &b[i][2]); for (i = 0; i < n; i+...
#include <bits/stdc++.h> using namespace std; const int N = 200002; vector<vector<pair<int, int> > > ans; vector<vector<int> > cs, twoCs, threeCs; int n, p[N]; int main() { ios::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) cin >> p[i]; bool mark[N] = {}; for (int i = 1; i <...
#include <bits/stdc++.h> using namespace std; int main() { deque<int> vec; int arr[200005]; int n, a; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &a); vec.push_back(a); arr[i] = 0; } for (int i = 0; i < n; i++) { scanf( %d , &a); int j = 0, i1...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int mod = 998244353; const int inv2 = (mod + 1) / 2; int n, m, k; int row_one[N], row_zero[N], col_one[N], col_zero[N]; int all_one, all_zero; int zero_r, zero_c, mul_r, mul_c; map<pair<int, int>, int> Map; int rval(int x) {...
#include <bits/stdc++.h> using namespace std; char op[600001]; long long id[600001], ans[600001], s[600001]; long long n, m, t; bool cmp(long long x, long long y) { long long pa, pb; if (op[x] == L ) { pa = ((s[x] - t) % m + m) % m; } else pa = (s[x] + t) % m; if (op[y] == L ) { ...
// "and_tree.v" // @vcs-flags@ -P pli.tab `timescale 1ps / 1ps // `include "standard.v" `include "standard.v-wrap" //----------------------------------------------------------------------------- module timeunit; initial $timeformat(-9,1," ns",9); endmodule module TOP; reg a, b, c, d; wire z; initial begin // ...
/** * 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; template <class T> void chkmin(T &a, T b) { if (a > b) a = b; } int n, s, m; int a[2005]; int z[2005], id[2005]; int dp[2][2005], f[2][2005]; int nxt[2005], prv[2005]; int ans; vector<int> v[2005]; int cnt; int pos[2005];...
#include <bits/stdc++.h> using namespace std; template <class T1, class T2> inline istream& operator>>(istream& fin, pair<T1, T2>& pr) { fin >> pr.first >> pr.second; return fin; } template <class T0, class T1, class T2> inline istream& operator>>(istream& fin, tuple<T0, T1, T2>& t) { fin >> get...
#include <bits/stdc++.h> #pragma optimization_level 3 #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 ) using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int main() { cin.tie(0); cout.tie(0); cin.sync_with_stdio(0); cout.sync_wit...
#include <bits/stdc++.h> #pragma GCC optimize( inline , 2) using namespace std; const long long N = 5005; const long long inf = 1e18; long long n, hd[N], nxt[N << 1], to[N << 1], w[N << 1], tot = 1; long long sz[N << 1]; long long aa[N << 1], eg[N << 1]; void add(long long a, long long b, long long c) {...
#include <bits/stdc++.h> using namespace std; int main() { int n, count = 0, max = 0; char line; cin >> n; n++; while (n--) { char temp; scanf( %c , &temp); if (temp == ) { if (count > max) max = count; count = 0; } else if (temp >= A && temp <= Z ) ...
/** * 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> int H[10]; int main() { memset(H, 0, sizeof(H)); for (int _n = 6, i = 0; i < _n; i++) { int v; scanf( %d , &v); H[v]++; } bool n6, n4, n5, n2; n6 = n4 = n5 = n2 = false; for (int _n = 10, i = 0; i < _n; i++) if (H[i] == 4) n4 = true; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> g(n + 1); vector<int> a(n); for (int i = 0; i < m; i++) { int maxj = 0; for (int j = 0; j < n; j++) { cin >> a[j]; if (a[j] > a[maxj]) maxj = j; else if (...
#include <bits/stdc++.h> using namespace std; int n; long long k; vector<vector<long long>> operator*(vector<vector<long long>> a, vector<vector<long long>> b) { vector<vector<long long>> ans(n, vector<long long>(n)); for (int i = 0; i < n; i++) { for (int j =...
// Copyright 1986-1999, 2001-2013 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2013.4 (lin64) Build 353583 Mon Dec 9 17:26:26 MST 2013 // Date : Mon Mar 17 09:47:36 2014 // Host : macbook running 64-bit Arc...
/* dcomp1.v - this is a fragment of a larger program, which would * dynamicly compute a more interesting value for the phdelay variable. * * It illustrates a problem in verilog-20010721 when computing * time values for use in behavioral delays. */ `timescale 1ps / 1ps module dcomp; time phdelay; paramet...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 9; const int MAX = 2e2 + 9; const double ep = 1e-6; const int mod = 998244353; const int INF = 0x3f3f3f3f; const double inf = 1e20; const double pi = acos(-1); vector<int> vec[maxn]; int n, m, k, d[maxn], cnt1, ans[maxn], tot; bo...
#include <bits/stdc++.h> using namespace std; const int MAXN = int(1e5 + 5); int n, A, cf, cm; int a[MAXN], tmp1[MAXN], tmp2[MAXN]; long long s[MAXN], m; int _max = 0, _min = int(1e9); bool cmp(int x, int y) { return a[x] < a[y]; } int main() { cin >> n >> A >> cf >> cm >> m; for (int i = 0; i <...