text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int MAXN = 207; int n, f[MAXN]; long long mmc_atual = 1; vector<int> folhas, Gr[MAXN]; bool in_cycle[MAXN], mrk[MAXN]; int marca_ciclo(int u) { if (in_cycle[u]) return 0; in_cycle[u] = true; return 1 + marca_ciclo(f[u]); } void dfsr(int u... |
/**
* ALU.v - Microcoded Accumulator CPU
* Copyright (C) 2015 Orlando Arias, David Mascenik
*
* 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
* ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: BMSTU
// Engineer: Oleg Odintsov
//
// Create Date: 20:41:53 01/18/2012
// Design Name:
// Module Name: videoctl
// Project Name: Agat Hardware Project
// Target Devices:
// Too... |
#include <bits/stdc++.h> using namespace std; template <class T> void read(T &x) { x = 0; char c = getchar(); int flag = 0; while (c < 0 || c > 9 ) flag |= (c == - ), c = getchar(); while (c >= 0 && c <= 9 ) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar(); if (flag) x = -x; ... |
// ----------------------------------------------------------------------
// Copyright (c) 2016, The Regents of the University of California All
// rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:... |
/**
* 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/1ns
module testbench;
parameter ADDRWIDTH = 4;
wire w_error, r_error;
reg rst_n = 1'b0;
reg w_clk = 1'b0;
reg r_clk = 1'b0;
wire #2 w_en = !w_full;
reg r_en = 1'b0;
wire w_full;
wire r_valid;
wire [ADDRWIDTH:0] r_counter;
wire [ADDRWIDTH:0] w... |
#include <bits/stdc++.h> using namespace std; int triangle(long long n) { if (n == 1) return 1; else return n + triangle(n - 1); } int heart(long long a) { if (a == 1) return 1; else return (6 * (a - 1)) + heart(a - 1); } int balls(long long a) { if (a == 1) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int minutes[n]; int result = -1; int lastN = 0; for (int i = 0; i < n; i++) { cin >> minutes[i]; if (i == 0 && minutes[0] > 15) { result = 15; } else if (result < 0 && minutes[i] - minutes[i... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFF = 0x3f3f3f3f3f3f3f3fll; const long long M = 1e9 + 7; const long long maxn = 1e6 + 7; const double pi = acos(-1.0); const double eps = 0.0000000001; long long gcd(long long a, long long b) { return b ? gcd(b, a... |
`timescale 1ns/1ns
module zmc(
input SDRD0,
input [1:0] SDA_L,
input [15:8] SDA_U,
output [21:11] MA
);
// Initialize ?
// Z80 ROM Region Reg
// 1E = F000~F7FF = F000~F7FF 1111 (0)
// 0E = E000~EFFF = E000~EFFF 1110 (1)
// 06 = C000~DFFF = C000~DFFF 110x (2)
// 02 = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int a[maxn], n, s, b[maxn], num[maxn], len; int ufs[maxn], meme[maxn]; inline int find(int u) { if (ufs[u] == u) return u; else return ufs[u] = find(ufs[u]); } inline void join(int u, int v, int e) { u = find(u... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 10:26:36 07/12/2015
// Design Name:
// Module Name: MemoryAdapter
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies: ... |
#include <bits/stdc++.h> using namespace std; const int maxn = (int)3e5 + 10; struct node { int nxt, to; } edg[maxn * 2]; int head[maxn], num; int f[maxn], n, a[maxn]; void add(int a, int b) { edg[++num].to = b; edg[num].nxt = head[a]; head[a] = num; } int k = 0; void dfs(int root) {... |
/*
Copyright (C) 2016 Cedric Orban
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 distributed in the ho... |
/*
* 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... |
//////////////////////////////////////////////////////////////////
// //
// Clock and Resets //
// //
// This file is part of the Amber project ... |
module memory (
input clk,
input [15:0] in,
input [14:0] address,
input [12:0] screen_read_address,
input load,
input [7:0] keyboard,
output [15:0] out,
// Screen
//output [12:0] screen_address, // ram address to write the pixel data
//output [15:0] screen_data, // pixel val... |
#include <bits/stdc++.h> using namespace std; long long x, y, p, q; int main() { int t; scanf( %d , &t); int x, y, p, q; while (t--) { scanf( %d %d %d %d , &x, &y, &p, &q); if (p == q) { printf( %d n , x == y ? 0 : -1); continue; } if (p == 0) { prin... |
#include<bits/stdc++.h> using namespace std; int a, b; bool check(int cnt) { int cnt6 = cnt/6; int cnt2 = cnt/2 - cnt6; int cnt3 = cnt/3 - cnt6; if(cnt2 <= a) { cnt6 -= a-cnt2; } if(cnt3 <= b) { cnt6 -= b-cnt3; } return cnt6 >= 0; } int main() { #ifdef DEBUG a = 0, b = ... |
/*
* blocksyn1.v
* This tests synthesis where statements in a block override previous
* statements in a block and also uses other previous statements in the
* block. Note in this example that the flag assignment is completely
* overruled by the conditional that is directly after it.
*/
module main;
reg [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... |
// -*- Mode: Verilog -*-
// Filename : burst_00.v
// Description : Test burst read/write interfacing
// Author : Philip Tracton
// Created On : Tue Jun 28 11:31:45 2016
// Last Modified By: Philip Tracton
// Last Modified On: Tue Jun 28 11:31:45 2016
// Update Count... |
////JAI SHREE RAM//// #include <iostream> #include<bits/stdc++.h> using namespace std; const long long int INF = (long long)1e15; const long long int mod = 1e9+7; #define ll long long #define f(i,a,b) for(int i=a;i<b;i++) #define pb push_back #define all(c) c.begin(),c.en... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 03/12/2016 06:18:20 PM
// Design Name:
// Module Name: Mux_Array
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long dp[255][255]; long long p[255], q[255], C[255][255]; int N; long long K; void init() { cin >> N >> K; p[0] = q[0] = C[0][0] = 1; for (int i = 1; i <= 250; i++) { p[i] = p[i - 1] * K % MOD; q[i] =... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.length(); bool ok = false; for (int i = 0; i < n - 1; i++) { if (s[i] == A && s[i + 1] == B ) { for (int j = i + 2; j < n - 1; j++) { if (s[j] == B && s[j + 1] == A ) { ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 28; const double INF = 1e12, EPS = 1e-9; int n, m, c[101]; void run() { cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; for (; a <= b; a++) c[a]++; } for (int i = 1; i <= n; i++) if... |
module soc_system (
button_pio_external_connection_export,
clk_clk,
dipsw_pio_external_connection_export,
hps_0_f2h_cold_reset_req_reset_n,
hps_0_f2h_debug_reset_req_reset_n,
hps_0_f2h_stm_hw_events_stm_hwevents,
hps_0_f2h_warm_reset_req_reset_n,
hps_0_h2f_reset_reset_n,
hps_0_hps_io_hps_io_emac1_inst_TX_CLK,... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, temp = 0; char x[5][5]; for (i = 0; i < 3; i++) gets(x[i]); for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) if (x[i][j] != x[2 - i][2 - j]) temp = 1; if (temp == 1) printf( NO n ); else printf( YES... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company: California State University San Bernardino
// Engineer: Bogdan Kravtsov
//
// Create Date: 13:26:15 10/03/2016
// Module Name: MUX_tb
// Project Name: MIPS
// Description: Testing MIPS 2-to-1... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; bool vis[100010]; vector<int> dp[5][100010]; int k, l; int a[6][6]; int dfs(int now) { int i, j, x = 0, sum = 0; for (i = 0; i < now; i++) x = x * 10 + a[now][i]; if (i == l - 1) return dp[1][x].size(); for (i = 0; i < dp[l - now][x].size(); i++)... |
/*
* Copyright (C) 2011 Kiel Friedt
*
* 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 p... |
/*
-- ============================================================================
-- FILE NAME : bus_master_mux.v
-- DESCRIPTION : oX}X^}`vNT
-- ----------------------------------------------------------------------------
-- Revision Date Coding_by Comment
-- 1.0.0 2011/06/27 suito VKì... |
/**
* 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, k; cin >> n >> k; int maxi = -1000000050; int f, t; int loli = -1000000050; for (int i = 0; i < n; i++) { cin >> f >> t; if (t > k) { loli = f - (t - k); } else loli = f; if (loli > maxi... |
#include <bits/stdc++.h> using namespace std; long long int n, m, k, s = 0, sx, sy, num; char grid[600][600]; bool vis[600][600]; long long int dx[4] = {0, 0, -1, 1}; long long int dy[4] = {-1, 1, 0, 0}; bool check(long long int x, long long int y) { if (x >= 0 && x < n && y >= 0 && y < m && grid[x][y... |
#include <bits/stdc++.h> const int mod = 1000000007; const int gmod = 3; const int inf = 1039074182; const double eps = 1e-9; const long long llinf = 2LL * inf * inf; template <typename T1, typename T2> inline void chmin(T1 &x, T2 b) { if (b < x) x = b; } template <typename T1, typename T2> inli... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; scanf( %d%d , &a, &b); for (int i = b + 1; i <= a + b + 1; i++) printf( %d , i); for (int i = b; i >= 1; i--) printf( %d , i); return 0; } |
#include <bits/stdc++.h> using ll = long long; using ull = unsigned long long; using std::cin; using std::cout; void print() {} template <typename T, typename... Args> void print(T t, Args... args) { cout << t << , print(args...); } template <typename... Args> void println(Args... args) { ... |
/**
* 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 i = 0; char a; char A[] = hello ; while (cin >> a && a != n ) { if (a == A[i]) i++; } if (i == 5) cout << YES << endl; else cout << NO << endl; } |
//*****************************************************************************
// (c) Copyright 2008 - 2010 Xilinx, Inc. All rights reserved.
//
// This file contains confidential and proprietary information
// of Xilinx, Inc. and is protected under U.S. and
// international copyright and other intellectual property
/... |
#include <bits/stdc++.h> using namespace std; int n; inline int f(int a) { int n1 = n; bool y = 0; while (n1 != 0) { int h = a; int u = n1 % 10; n1 = n1 / 10; while (h != 0) { int j = h % 10; h = h / 10; if (u == j) { y = 1; break; ... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
//
/*
Copyright 2010, 2011 David Fritz, Brian Gordon, Wira Mulia
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... |
// ***************************************************************************
// ***************************************************************************
// Copyright 2011(c) Analog Devices, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// a... |
// The IEEE standard allows the out-of-bounds part-selects to be flagged as
// compile-time errors. If they are not, this test should pass.
module top;
reg [3:0][3:0] array;
reg failed = 0;
initial begin
array = 16'h4321;
$display("%h", array[-2+:2]); if (array[-2+:2] !== 8'hxx) failed = 1;
$display("%h", arr... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int *b = new int[n]; int max_val = 0; for (int i = 0; i < n; i++) { cin >> b[i]; if (i == 0) { } else if (i == 1) { b[i] = b[0] + b[1]; max_val = (b[0] > b[1]) ? b[0] : b[1]; } els... |
/*
* 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... |
/*
File: parallella_gpio_emio.v
This file is part of the Parallella FPGA Reference Design.
Copyright (C) 2013-2014 Adapteva, Inc.
Contributed by Fred Huettig
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 Fr... |
#include <bits/stdc++.h> #pragma GCC optimize( -O3 ) using namespace std; const long long mod = 998244353; struct edge { int u, v, cap; edge() {} edge(int _u, int _v, int _cap) : u(_u), v(_v), cap(_cap) {} int get(int t) { return t ^ u ^ v; } }; const int inf = 1e9; struct edkarp { vec... |
// file: ibert_7series_gtx_0.v
//////////////////////////////////////////////////////////////////////////////
// ____ ____
// / /\/ /
// /___/ \ / Vendor: Xilinx
// \ \ \/ Version : 2012.3
// \ \ Application : IBERT 7Series
// / / Filename : example_ibert_7series_gtx_0
// /_... |
#include <bits/stdc++.h> using namespace std; const int N = (2e5 + 5); const int mod = 1e9 + 7; long long int n, a[N], x; vector<vector<int>> g; long long int pow_mod_m(long long int a, long long int n) { if (!n) return 1; long long int pt = pow_mod_m(a, n / 2); pt *= pt; pt %= mod; if (... |
/*
* 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() { vector<string> a; vector<string> z; string s; while (cin >> s) { a.push_back(s); } int ans = 0; sort(a.begin(), a.end()); for (int r = 0; r < 720; r++) { if (a[0].length() + a[5].length() == a[3].length() + 1 && ... |
#include <bits/stdc++.h> int main() { long n; scanf( %ld n , &n); std::vector<long> blocks(n + 2); for (long p = 1; p <= n; p++) { scanf( %ld , &blocks[p]); } for (long p = 1; p <= n; p++) { blocks[p] = std::min(blocks[p], 1 + blocks[p - 1]); } for (long p = n; p >= 0; p--)... |
#include <bits/stdc++.h> using namespace std; int a[10]; int main() { int ans = 0; for (int i = 0; i < 6; i++) scanf( %d , &a[i]); if (a[2] == a[4]) { swap(a[0], a[3]); swap(a[1], a[2]); swap(a[4], a[5]); } for (int i = a[0] + a[0] - 1 + 2, j = 0; j < max(a[1], a[5]); i += 2,... |
`timescale 1ns / 1ps
/*
* File : Processor.v
* Project : University of Utah, XUM Project MIPS32 core
* Creator(s) : Grant Ayers ()
*
* Modification History:
* Rev Date Initials Description of Change
* 1.0 23-Jul-2011 GEA Initial design.
* 2.0 26-May-2012 GEA ... |
#include <bits/stdc++.h> using namespace std; int main() { int i; int a, b; int draw = 0, awin = 0, bwin = 0; cin >> a >> b; for (i = 1; i < 7; i++) { if (abs(i - a) == abs(i - b)) draw++; else if (abs(i - a) > abs(i - b)) bwin++; else awin++; } ... |
#include <bits/stdc++.h> using namespace std; int n; int m; struct Edge { int x; int y; int t; Edge(int x, int y, int t) : x(x), y(y), t(t) {} void print() { cout << x << << y << << t << endl; } }; vector<Edge> edges; vector<int> edge_idx[200005]; int in_digree[200005]; que... |
//#############################################################################
//# Purpose: Low power standby state machine #
//#############################################################################
//# Author: Andreas Olofsson #
... |
#include <bits/stdc++.h> using namespace std; long long powmod(long long base, long long exponent, long long mod) { long long ans = 1; while (exponent) { if (exponent & 1) ans = (ans * base) % mod; base = (base * base) % mod; exponent /= 2; } return ans; } long long gcd(long lo... |
// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2015.4
// Copyright (C) 2015 Xilinx Inc. All rights reserved.
//
// ==============================================================
`timescale 1ns/1ps
module ... |
#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 INF = 1e9; const int MOD = 1e9 + 7; vector<int> prefix_function(vector<int> s) { int n = s.size(); vector<int> pi(n); pi[0] = 0; for (int i = 1; i < n; ++i) { int j = pi[i - 1]; while (j > 0 && s[i] != s[j]) { j = pi[j -... |
#include <bits/stdc++.h> using namespace std; const long long N = 400010; inline long long read() { long long s = 0, w = 1; register char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = (s << 3) + (s <... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int N = 3e5 + 5; const int INF = 1e9 + 7; vector<int> graph[N]; multiset<int, greater<int>> st; int n, a, b, dat[N], ans, cur; void rem(int val) { auto it = st.find(val); st.erase(it); } int main() { ios_base... |
//
// 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... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int INF = (int)1e9; const long long LINF = (long long)1e18; const long double PI = 2 * acos((long double)0); long long gcd(long long a, long long b) { long long r; while (b) { r = a % b; a = b; b = r;... |
#include <bits/stdc++.h> using namespace std; bool comp(int a, int b) { return (a > b); } int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main(void) { long long int n, m, k; cin >> n >> m >> k; if (k > (n + m - 2)) { cout << -1 ; retu... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,unroll-loops,no-stack-protector ) using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 3005; map<int, vector<int> > dif; vector<int> mod[8]; int a[N]; int n; template <class C, class F> struct Mcm... |
///////////////////////////////////////////////////////////////////////////
//
// To test:
// (a) The use & representation of time variables
// (b) The display of time variables
//
// Compile and run the program
// iverilog tt_clean.v
// vvp a.out
//
// VISUALLY INSPECT the displays. (There... |
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } const int INF = (((1 << 30) - 1) << 1) + 1; const int nINF = 1 << 31; pair<long long, long long> egcd(long long a, long long b, pair<long long, long long> x = {1, 0... |
// 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(/*AUTOARG*/
// Inputs
clk
);
input clk;
reg _ranit;
/*AUTOWIRE*/
// Begi... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFF = 0x3f3f3f3f3f3f3f3f; const double pi = acos(-1.0); const double eps = 1e-9; const long long mod = 1e9 + 7; int read() { int x = 0, f = 1; char ch = getchar(); while (ch< 0 | ch> 9 ) { if (ch... |
#include <bits/stdc++.h> using namespace std; template <class T> bool uin(T &a, T b) { return (a > b ? a = b, true : false); } template <class T> bool uax(T &a, T b) { return (a < b ? a = b, true : false); } int const X = 8; int const L = 16; int const N = 41; long long const INF = 3e18 + ... |
/////////////////////////////
//LAB01 29/05 - Atividade 1//
/////////////////////////////
module Mod_Teste(
input CLOCK_27,
input CLOCK_50,
input [3:0] KEY,
input [17:0] SW,
output [6:0] HEX0,
output [6:0] HEX1,
output [6:0] HEX2,
output [6:0] HEX3,
output [6:0] HEX4,
output [6:0] HEX5,
outpu... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; vector<vector<int>> v(200001, vector<int>(32)); for (int i = 0; i < 2e5 + 1; i++) { for (int j = 0; j < 32; j++) { if (i & (1 << j)) v[i][j] = 1; } } for (int i = 1; i < 2e5 + 1; i++) { for ... |
//Legal Notice: (C)2011 Altera Corporation. All rights reserved. Your
//use of Altera Corporation's design tools, logic functions and other
//software and tools, and its AMPP partner logic functions, and any
//output files any of the foregoing (including device programming or
//simulation files), and any associated do... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 150001; int t[MAX_N]; int main() { int n, k, q; cin >> n >> k >> q; for (int i = 0; i < n; ++i) { cin >> t[i]; } set<int> s; for (int i = 0; i < q; ++i) { int x, y; cin >> x >> y; if (x == 1) { ... |
#include <bits/stdc++.h> using namespace std; long long n, k, a[100100], sum = 0, Min = 1e6; int main() { cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { if (a[i] < 0 && k) a[i] *= -1, k--; Min = min(Min, abs(a[i])); sum += a[i]; } if (k ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353, N = 1e6 + 5; long long fact[N], d[N]; long long f(int x) { if (x == 0) return 1; if (fact[x] != 0) return fact[x]; return fact[x] = (x * f(x - 1)) % MOD; } int main() { d[1] = 1; for (int i = 2; i < N; i++) { ... |
#include <bits/stdc++.h> using namespace std; int N, R; int result = INT_MAX; char opt[] = TB ; int turns; int sLast; char rChar[1000001]; int main() { int x, y; cin >> N >> R; if (N == 1 && R == 1) { cout << 0 << endl << T << endl; return 0; } for (int i = 1; i < R; i... |
#include <bits/stdc++.h> using namespace std; const long long int N = 1e6 + 5; const long long int INF = 1e18; const long long int MOD = 1e9 + 7; int a[N], has[N], hol[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long int n, m, k, u, v; cin >> n >> m >> k; ... |
#include <bits/stdc++.h> using namespace std; const int N = 10000; const int M = 1000000; const int inf = 1e9; struct Edge { int v, w, cost, next; } g[M]; int head[N], st, ed, flow, cost, cnt; void init() { memset(head, -1, sizeof(head)); flow = cost = cnt = 0; } void addEdge(int u, int ... |
#include <bits/stdc++.h> #pragma GCC target( pclmul ) using ul = std::uint32_t; using ull = std::uint64_t; using li = std::int32_t; using ll = std::int64_t; using llf = long double; using uss = std::uint8_t; const ul tau = 15; const ul fib[] = { 1, 1, 2, 3, 5, 8, ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > v(200002); bool ab[200002]; int dist[200002]; queue<int> q; int cur, i, n, h[200002], r[200002], p[200002]; void dfs() { while (!q.empty()) { cur = q.front(); q.pop(); ab[cur] = true; for (i = 0; i < v[cur].size... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int a, b, k, v; bool check(int x) { return min(x * k, (x + b)) * v >= a ? true : false; } int main() { scanf( %d%d%d%d , &k, &a, &b, &v); for (int i = 1; i <= 1000; i++) { if (check(i)) { printf( %d n , i); ... |
#include <bits/stdc++.h> using namespace std; long long n, v[500005], lastLeft[500005], lastRight[500005], solLeft[500005], solRight[500005], sol[500005]; int main() { cin >> n; for (int i = 1; i <= n; ++i) { cin >> v[i]; } for (int i = 1; i <= n; ++i) { lastLeft[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... |
// USED ONLY TO SELECT PL BLOCKED STATUS
// OPTIMISE FOR XY ROUTING
/* autovdoc@
*
* component@ unary_select_pair
* what@ A sort of mux!
* authors@ Robert Mullins
* date@ 5.3.04
* revised@ 5.3.04
* description@
*
* Takes two unary (one-hot) encoded select signals and selects one bit of the input.
*
* Imp... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; int ans = 1e9; for (int i = 1; i * i <= n; i++) { ans = min(ans, i - 1 + (n - i + i - 1) / i); } ... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; int n, t; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> t; while (t--) { cin >> n; if (n <= 2) { cout << 0 << endl; continue; } else { int x; x = n / 2; if (n % ... |
#include <bits/stdc++.h> using namespace std; template <typename T> T Abs(T first) { return (first < 0 ? -first : first); } template <typename T> T Sqr(T first) { return (first * first); } string plural(string s) { return (int((s).size()) && s[int((s).size()) - 1] == x ? s + en ... |
/**
* 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... |
// megafunction wizard: %ROM: 1-PORT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: rom.v
// Megafunction Name(s):
// altsyncram
//
// Simulation Library Files(s):
// altera_mf
// ====================================... |
#include <bits/stdc++.h> const int MAXN = 2e5 + 7; struct Edge { int t, next; } edge[MAXN << 1]; int head[MAXN], cnt; int size[MAXN]; int dfn[MAXN], pos[MAXN], ts = 0; int n, m; int dist[MAXN], deep[MAXN]; int f[MAXN][19]; int t1 = 1, t2 = 1; struct SegmentTree; struct Questions; SegmentTr... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long n; cin >> n; vector<vector<long long> > p(2, vector<long long>(n)), suf(2, vector<long long>(n + 1)), ebalVLevo(2, vector<long long>(n + 1)), ebalVPravo(2, vector<long long>(n + 1))... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.