text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } template <class T> o... |
// -- (c) Copyright 2009 - 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
// -- laws.
// --
// -- DISCLAIMER
// -- This disclaimer is not a... |
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << endl; err(++it, args...); } long long powMod(long long x, long long y) { long lon... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int pref[N]; vector<int> v; int fsoma(int l, int r) { l--; int ans = pref[r]; if (l >= 0) ans -= pref[l]; return ans; } long long n, k, l; void rbest(pair<int, int> &a, pair<int, int> b) { if (b.first > a.first or ... |
#include <bits/stdc++.h> using namespace std; const long long limita = 998244353; long long n, v[200], st, dr, mij, mul, ans, maxDegree; long long GCD(long long x, long long y) { if (y != 0) return GCD(y, x % y); else return x; } int main() { ios::sync_with_stdio(false); cin.tie(... |
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <iostream> #include <algorithm> #include <queue> #include <map> #include <set> #include <vector> #include <string> #include <stack> #include <numeric> #include <cassert> #define endl n ... |
/*
* 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 int N = 300005; int n; int ans = 300005, pos = 1; long long tnow, wnow; struct node { long long t, w; } a[N]; priority_queue<long long, vector<long long>, greater<long long> > q; bool cmp(node a, node b) { return a.t > b.t; } int main() { s... |
/**
* 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... |
/////////////////////////////////////////////////////////////////////////
//
// XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
// SOLELY FOR USE IN DEVELOPING PROGRAMS AND SOLUTIONS FOR
// XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION
// AS ONE POSSIBLE IMPLEMENTATI... |
module ram(input [11:0] adr, input we,
inout [31:0] data);
reg [31:0]ram[11:0];
integer i = 0;
//Op Codes
parameter NOP = 4'b0000;
parameter LOAD = 4'b0001;
parameter STORE = 4'b0010;
parameter BRANCH = 4'b0011;
parameter XOR = 4'b0100;
parameter ADD = 4'b0101;
parameter ... |
// (c) Copyright 1995-2014 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 ... |
// ----------------------------------------------------------------------------
// Module: alu.v
// Project: MOS 6502 Processor
// Author: George Castillo
// Date: Sat Jul 8 15:31:17 2017
//
// Description: Arithmetic-logic unit for the MOS 6502 processor.
//
// Usage: The ALU is used by the processor to ... |
//altera message_off 10230
`timescale 1 ps / 1 ps
module alt_mem_ddrx_list
# (
// module parameter port list
parameter
CTL_LIST_WIDTH = 3, // number of dram commands that can be tracked at a time
CTL_LIST_DEPTH = 8,
CTL_LIST_INIT_VALUE_TYPE = ... |
#include <bits/stdc++.h> #pragma GCC optimize(3, Ofast , inline ) using namespace std; const long long INF(0x3f3f3f3f3f3f3f3fll); const long long inf(0x3f3f3f3f); template <typename T> void read(T &res) { bool flag = false; char ch; while (!isdigit(ch = getchar())) (ch == - ) && (flag = true)... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; struct node { int x, y; } point[maxn]; bool check(node a, node b, node c, node d) { if (a.x - b.x == c.x - d.x && a.y - b.y == c.y - d.y) return true; return false; } int main() { int n; cin >> n; for (int 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; inline long long add(long long x, long long y) { x += y; if (x >= 1000000007) x -= 1000000007; return x; } inline long long sub(long long x, long long y) { x -= y; if (x < 0) x += 1000000007; return x; } inline long long mul(long long x, ... |
#include <bits/stdc++.h> using namespace std; unsigned long long n, k, c, a, b, d; multiset<unsigned long long> vn; multiset<unsigned long long> vk; unsigned long long mod = 1e9 + 7; unsigned long long sum = 0; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; cin >... |
#include <bits/stdc++.h> using namespace std; int a[1010]; int main() { int n, k; scanf( %d%d , &n, &k); for (int i = 0; i < n; i++) scanf( %d , &a[i]); sort(a, a + n); int ans = 0; for (int i = 0; i < n; i++) { if (a[i] <= k * 2) { k = max(k, a[i]); continue; }... |
#include <bits/stdc++.h> int const maxl = 22; int const maxm = 2520; long long f[maxl][maxm + 4][50][2]; int a[maxl]; std::vector<int> alcm; long long plcm[maxm + 4][10]; long long kth[maxm + 4]; long long l, r; int gcd(int x, int y) { return !y ? x : gcd(y, x % y); } int lcm(int x, int y) { if ... |
#include <bits/stdc++.h> using namespace std; long long vis[1009]; vector<long long> v[1000]; long long th, n; void dfs(long long s) { if (vis[s]) return; vis[s] = 1; for (long long i = 0; i < v[s].size(); i++) { if (s <= n) th++; dfs(v[s][i]); } } int main() { ios_base::sy... |
/**
* 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 findMaximalK(int n); using namespace std; int main() { int n, b, p, x, y; cin >> n >> b >> p; y = n * p; x = 0; int remaining = n; while (remaining > 1) { int doingMatch = pow(2, findMaximalK(remaining)); x += doingMatch * b + doingMatch / 2; ... |
#include <bits/stdc++.h> using namespace std; int N; bool indegree[200010]; int a[200010]; bool visited[200010]; vector<pair<int, int> > ans; int main() { int i, j, k; scanf( %d , &N); for (i = (0); i < (N); i++) scanf( %d , a + i); for (i = (0); i < (N); i++) a[i]--; memset((visited),... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 5; int n; pair<long long, int> t[N]; long long tree[4 * N], dp[N], v[N]; int rnk[N]; inline void update(int idx, long long val, int st, int en, int root) { if (idx < st || idx > en) return; if (st == en) { tree[root] = ma... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; int pre[N], rak[N]; int find(int first) { if (pre[first] == -1) return first; return pre[first] = find(pre[first]); } void unions(int first, int second) { first = find(first); second = find(second); if (first == second)... |
// test_simulation_techmap_and_19_tech.v
module f1_TECH_AND18(input [17:0] in, output out);
assign out = ∈
endmodule
module f1_TECH_AND4(input [3:0] in, output out);
assign out = ∈
endmodule
// test_simulation_techmap_and_5_tech.v
module f2_TECH_AND5(input [4:0] in, output out);
assign out = ∈
endmodule
//... |
/*
* 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... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 19:19:08 12/01/2010
// Design Name:
// Module Name: sd_dma
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
/... |
module LcdBridge(rst_n, clk, rs, rw, e, d, cs, sck, mosi, miso);
input rst_n, clk, cs, sck, mosi;
output rs, rw, e, miso;
// d is bidirectional port
inout [7:0] d;
wire [7:0] outData;
wire dFlag; // if dFlag == 1, d is output
assign d = dFlag ? outData : 8'bzzzz_zzzz;
wire [7:0] ctl, data, ret_data;
wire divClk;
Cl... |
#include <bits/stdc++.h> template <typename C> int sz(const C &c) { return c.size(); } using namespace std; int main() { iostream::sync_with_stdio(false); int64_t n; cin >> n; int k; cin >> k; int64_t maxV = 0; int maxI = 1; int64_t maxC = 0; for (int i = 1; i <= k; ++i... |
#include <bits/stdc++.h> using namespace std; struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } } _io; const long long maxn = 3e5 + 10, mod = 1e9 + 7; template <typename... T> long long madd(T... args) { long long res = 0; for (auto i : {args...}) { ... |
`timescale 1ns/1ps
module SensorFSM #(
parameter DataWidth = 8
) (
input Reset_n_i,
input Clk_i,
// top level
input Enable_i,
output reg CpuIntr_o,
output [2*DataWidth-1:0] SensorValue_o,
// to/from Measure-FSM
... |
/**
* 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 "bsg_defines.v"
module bsg_mem_1rw_sync_mask_write_var #
(parameter `BSG_INV_PARAM(width_p)
,parameter `BSG_INV_PARAM(mask_width_p)
,parameter `BSG_INV_PARAM(els_p)
,parameter chunk_size_lp = width_p / mask_width_p
,parameter addr_width_lp=`BSG_SAFE_CLOG2(els_p))
(input clk_i
... |
#include <bits/stdc++.h> using namespace std; int n = 0, a, tc; int p[100005]; vector<int> cho[6][100005]; int sum[6]; int ret = 0; void doit(int x, int cur) { if (x == n - 1) { ret += cho[x + 5 - n][cur].size(); return; } for (int i = 0; i < cho[x + 5 - n][cur].size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000 + 7; const long long LINF = 1LL * INF * INF; const int MAX = 1e5 + 7; const double PI = acos(-1.); const double EPS = 1e-7; const int MOD = 998244353; const int MAXF = 1000000000; int dx[] = {1, -1, 0, 0}; int dy[] = {0... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; int read() { int s = 0; char c = getchar(), lc = + ; while (c < 0 || 9 < c) lc = c, c = getchar(); while ( 0 <= c && c <= 9 ) s = s * 10 + c - 0 , c = getchar(); return lc == - ? -s : s; } void write(int x) { if (x < 0) { putc... |
// megafunction wizard: %LPM_ADD_SUB%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: LPM_ADD_SUB
// ============================================================
// File Name: add.v
// Megafunction Name(s):
// LPM_ADD_SUB
//
// Simulation Library Files(s):
// lpm
// ========================================... |
#include <bits/stdc++.h> using namespace std; string inc[6] = { 011112 , 103231 , 110121 , 121011 , ,112101 , 211110 }; string near[6] = { 1234 , 0254 , 0153 , 4520 , 3510 , 4321 }; int opp[6] = {5, 3, 4, 1, 2, 0}; char t[7], s[7]; string t_p; bool seen[6]; set<string> se; void dfs(int x, in... |
#include <bits/stdc++.h> using namespace std; vector<int> x_coord, y_coord; vector<vector<int>> adj; vector<bool> used; int n; void dfs(int v) { used[v] = true; for (auto u : adj[v]) { if (!used[u]) { used[u] = true; dfs(u); } } } int main() { scanf( %d , &n);... |
#include <bits/stdc++.h> using namespace std; const int N = 501; int n, k; int C[N]; bool Dp[N][N][N]; vector<int> Ans; int main() { scanf( %d%d , &n, &k); for (int i = 0; i < n; i++) scanf( %d , C + i); Dp[n][0][0] = true; for (int idx = n - 1; idx >= 0; idx--) for (int Sum = 0; Sum... |
#include <bits/stdc++.h> using namespace std; long long dx[] = {1, 0, -1, 0}; long long dy[] = {0, 1, 0, -1}; bool myComparison1(const pair<long long, long long> &a, const pair<long long, long long> &b) { return a.second < b.second; } bool myComparison2(const pair<long long, long lo... |
#include <bits/stdc++.h> using namespace std; const int N = 105; const int inf = 10000000; int n, k; int l[N], r[N]; int main() { scanf( %d%d , &n, &k); int midx = (k + 1) / 2, midy = (k + 1) / 2; for (int i = 0; i < n; i++) { int m, ans = inf, x, y1, y2; scanf( %d , &m); for (... |
#include <bits/stdc++.h> using namespace std; int a[150], b[150]; void put(int x, int y[]) { if (x == 1) y[1] = 1; else if (x == 2) { y[1] = 3; y[2] = 4; } else { for (int i = 1; i <= x - 1; i++) y[i] = 2; y[x] = x - 2; } } int main() { int n, m; scanf( %d... |
module packet_builder #(parameter NUM_CHAN = 1)(
// System
input rxclk,
input reset,
input [31:0] adctime,
input [3:0] channels,
// ADC side
input [15:0]chan_fifodata,
input [NUM_CHAN:0]chan_empty,
input [9:0]chan_usedw,
output reg [3:0]rd_select,
output reg chan_rdreq,
// FX... |
/**
* 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; int a[n][2]; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; } int sum1 = 0; int sum2 = 0; for (int i = 0; i < n; i++) { if (abs(sum1 + a[i][0] - sum2) <= 500) { sum1 += a[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... |
//================================================================--
// Design Unit : sn7402 (behaviour)
//
// File Name : behaviour.v
//
// Purpose : model of TTL SN7402 quad and IC
//
// Author : Daniel Guenther, Vancouver Island University
//
// Environmant : Icarus
//-----------------------------------------------... |
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 14:06:45 03/31/2015
// Design Name:
// Module Name: Adder64
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
//... |
module voice(clk, gate, note, pitch, lfo_sig, lfo_depth, lfo_depth_fine, wave_form, signal_out);
input wire clk;
input wire gate;
input wire [6:0] note;
input wire [7:0] lfo_sig;
input wire [6:0] lfo_depth;
input wire [6:0] lfo_depth_fine;
input wire [13:0] pitch;
output wire [7:0] signal_out;
//input wire [31:0] adde... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10, mod = 1e9 + 7; const long long infl = LLONG_MAX / 2; int n, ans, h[N]; vector<int> g[N], L; void dfs(int u = 0, int p = -1) { bool leaf = 1; for (int x : g[u]) if (x - p) { h[x] = h[u] + 1; dfs(x, u); ... |
#include <bits/stdc++.h> using namespace std; int main() { double n, m, a; cin >> n >> m >> a; cout << (long long)(ceil(n / a) * ceil(m / a)); return 0; } |
#include <bits/stdc++.h> using namespace std; inline void io() {} int main() { ios_base::sync_with_stdio(false); cin.tie(); cout.tie(); cout << fixed << setprecision(8); long long int n, a, b, c = 0, k; cin >> a >> b >> n; for (int i = 0; i < 10; i++) { if (((a * 10) + i) % b == ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= 500; i++) putchar( 9 ); for (int i = 1; i <= 500; i++) putchar( 0 ); putchar( 1 ); putchar( n ); for (int i = 1; i <= 501; i++) putchar( 9 ); return 0; } |
// Zhiyang Ong
// Andrew Mattheisen
// EE577b Troy WideWord Processor Project
// make module match terms in module defn'
module pipe2(aluop_in, aluop_out,
ww_in, ww_out,
memEn_in, memEn_out,
memWrEn_in, memWrEn_out,
memAddr_in, memAddr_out,
wbyteen_in, wbyteen_out,
regwren_... |
#include <bits/stdc++.h> using namespace std; struct Timer { chrono::time_point<chrono::high_resolution_clock> start, end; chrono::duration<float> dur; Timer() { start = chrono::high_resolution_clock::now(); } ~Timer() { end = chrono::high_resolution_clock::now(); dur = end - start; ... |
/**
* 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... |
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2015 by Wilson Snyder.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
integer cyc; initial cyc=1;
parameter ONE = 1;
wire [17:10] bitout;
reg [7:0] allbi... |
/**
* 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() { string s; cin >> s; cout << s; for (int i = s.size() - 1; i >= 0; i--) { cout << s[i]; } return 0; } |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long n, m; cin >> n >> m; if (m % 2 == 1) { bool f = true; long ptr = (m + 1) / 2; long p1 = ptr - 1, p2 = ptr; for (long i = 1; i <= n; i++) { if (f && p2 ... |
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { int a; cin >> a; if (a % 2 == 0) cout << a - 1 << ; else cout << a << ; } } |
// ==============================================================
// File generated by Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC
// Version: 2017.2
// Copyright (C) 1986-2017 Xilinx, Inc. All Rights Reserved.
//
// ==============================================================
`timescale 1ns/1ps
... |
/*
* 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 bool online_judge = true; const long long inf = 1LL << 60; long long toInt(string s) { long long res; stringstream ss; ss << s; ss >> res; return res; } string toString(long long n) { stringstream ss; ss << n; return ss.str(... |
#include <bits/stdc++.h> int main() { long long l3, l4, l5; std::cin >> l3 >> l4 >> l5; long double pi = 3.141592653589793238462643383279; long double v3 = 1.0 / 3.0 * l3 * l3 * sqrtl(3.0) / 4.0 * l3 * sqrtl(2.0 / 3); long double v4 = 1.0 / 3.0 * l4 * l4 * l4 * sqrtl(2) / 2; long double v5 = 1... |
/*
Testbench for Average Filter
By Hsiang-Yi Chung
February, 2016
*/
`timescale 1 ns / 1 ps
module tb_avg_filter;
reg [11:0] in;
reg [10:0] dummy;
reg clk;
wire out_ready;
wire [11:0] out1;
wire [11:0] out2;
reg [16:0] test;
reg [5:0] i,j;
reg [16:0] tb_result1, tb_result2;
Average_Filter filter (.in(i... |
#include <bits/stdc++.h> using namespace std; template <typename T, size_t N> long long SIZE(const T (&t)[N]) { return N; } template <typename T> long long SIZE(const T &t) { return t.size(); } string to_string(const string s, long long x1 = 0, long long x2 = 1e9) { return + ((x1 < s.siz... |
#include <bits/stdc++.h> using namespace std; vector<long long> graph[100005]; vector<pair<long long, long long> > graph_p[100005]; vector<pair<long long, long long> > op; vector<long long> vis(100005, 0); long long power(long long x, long long y) { long long res = 1; x = x % 1000000009; if (x =... |
/*
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law... |
#include <bits/stdc++.h> using namespace std; int t, n, k; char s[4000]; int opx[4000]; int opy[4000]; int count2; void Reverse(char *s, int a, int b) { for (int i = a, j = b; i < j; i++, j--) { char c = s[i]; s[i] = s[j]; s[j] = c; } } int main() { cin >> t; while (t... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t, n; cin >> t; while (t--) { string A, B; cin >> n; cin >> A >> B; int f = 1; for (int i = 0; i < n; ++i) { if (A[i] > B[i]) f = 0; ... |
#include <bits/stdc++.h> using namespace std; int z[100001]; int main() { string s; int T, a, b; cin >> s; for (a = 1; a < s.size(); a++) { z[a] = z[a - 1] + (s[a] == s[a - 1]); } for (cin >> T; T--; cout << z[b - 1] - z[a - 1] << endl) cin >> a >> b; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, x; set<int> ase; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &x); if (ase.size() >= x) { ase.insert(x); } else { cout << i << endl; return 0; } } cout << -1 << 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... |
//----------------------------------------------------------------------------
//-- Prueba de tranmision 3. Transmision periódica del caracter K, cada
//-- 250ms
//----------------------------------------------------------------------------
//-- (C) BQ. September 2015. Written by Juan Gonzalez (Obijuan)
//-- GPL licens... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(10); int n; cin >> n; if (n % 2) { cout << black n ; } else { cout << white n ; cout << 1 << << 2 << endl; } retu... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, flag = 0, i, j; cin >> a >> b >> c; for (i = 0; i <= c; i++) { for (j = 0; j <= c; j++) { if (a * i + b * j == c) { flag = 1; break; } } if (flag == 1) break; } if (flag ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 510; int m; long long n, ans; int cnt, head[N]; struct edge { int to, next; } e[1010]; void ade(int u, int v) { e[++cnt] = (edge){v, head[u]}; head[u] = cnt; } long long getsize(long long num) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void print_array(T arr[], int size_arr) { for (int i = (0); i < (size_arr); i++) { cout << arr[i]; if (i == size_arr - 1) cout << endl; else cout << ; } } template <typename T> void print_vector(... |
/**
* 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... |
// -------------------------------------------------------------
//
// Generated Architecture Declaration for rtl of inst_eb_e
//
// Generated
// by: wig
// on: Thu Jul 6 05:51:58 2006
// cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl ../autoopen.xls
//
// !!! Do not edit this file! Autogenerated by MIX !!!
// $Autho... |
#include <bits/stdc++.h> using namespace std; const int N = 3000 + 5; int n, m; int l[N][N], r[N][N], cnt[N], fen[N]; char s[N][N]; vector<int> del[N]; void up(int x, int k) { cnt[x] += k; for (; x; x -= x & -x) fen[x] += k; } int get(int x) { int res = 0; for (; x < N; x += x & -x) re... |
/**
* 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 la... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e6 + 5; long long dp[105], cnt[105], b[N], a[N]; void add(long long &a, long long b) { a += b; if (a >= mod) a -= mod; } struct Mat { long long t[101][101]; Mat() { memset(t, 0, sizeof t); } } I; int ... |
/*
Copyright (c) 2015 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; int a[1505]; int main() { ios::sync_with_stdio(false), cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } bool isEven = true; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (... |
#include <bits/stdc++.h> using namespace std; const int DN = 3e5 + 5; int n, m, sol, f, cnt, mi = 1e9, sum; char ch[6], a[5][5], car; string s[DN], r[DN]; void solve1() { cnt++; sum = 0; int f, mi; for (int i = 1; i <= n; i++) { f = 0; for (int j = 1; j <= m; j++) { car =... |
#include <bits/stdc++.h> using namespace std; long long n, i, j, ans = 0; long long a, b; const long long M = (long long)1E9 + 7; long long power(long long x, long long y) { long long res = 1; x %= M; while (y) { if (y % 2) res = (res * x) % M; y = y >> 1; x = (x * x) % M; } ... |
#include <bits/stdc++.h> using namespace std; int n, m; int dp[800][800][10]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) { int x, y; scanf( %d%d , &x, &y); dp[x][y][1]++; dp[y][x][1]++; } for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++... |
#include <bits/stdc++.h> using namespace std; int n, a[110], b[110], sum = 0; pair<int, int> dp[110][11000], q = {-1, -1}; pair<int, int> Rec(int i, int W) { if (i == n) { if (W >= sum) return {0, 0}; else return {1e9, 1e9}; } if (dp[i][W] != q) return dp[i][W]; pair<... |
/**
* 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; using ll = long long; template <typename A, typename B = A> using pr = pair<A, B>; int main() { ios::sync_with_stdio(false), cin.tie(nullptr); cout << fixed << setprecision(10); int sy, a, b; cin >> sy >> a >> b; sy = -sy; int n; cin >>... |
/**
* 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.