text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int rc = 0, uc = 0, c = 0; for (int i = 0; i < n; i++) { if (s[i] == R ) rc++; else uc++; if (rc == uc && s[i] == s[i + 1]) c++; } cout << c << n ; ...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> const int INF = 0x3f3f3f3f; const int maxn = 1e5 + 50; const int Mod = 1e6 + 3; using namespace std; const char YES[] = YES , NO[] = NO ; int n; int s[maxn]; bool find(int &st) { st = n - 2; if (st <= 0) return false; while (st > 0 && s[st] != 0) st--; return s...
#include <bits/stdc++.h> using namespace std; inline void proc_status() { ifstream t( /proc/self/status ); cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl; } template <typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } t...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 14:55:04 12/14/2010 // Design Name: // Module Name: msu // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // // Revision: // R...
//====================================================================== // // poly1305.v // ---------- // Poly1305 Verilog behavioral model. // // // Copyright (c) 2016, Secworks Sweden AB // Joachim Strömbergson // // Redistribution and use in source and binary forms, with or // without modification, are permitted pr...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse2 ) using namespace std; const int N = 2020; namespace Gause { static const int N = ::N; int equ, var; bitset<N> a[N]; int x[N]; int free_x[N]; int free_num; int l[N]; void ini(...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<vector<long long int>> grid(51, vector<long long int>(51, 0)); vector<pair<long long int, long long int>> a; int t1 = 4 * n + 1; while (t1--) { int u, v; ...
#include <bits/stdc++.h> int compare(const void *a, const void *b) { long long la = *(long long *)a; long long lb = *(long long *)b; return la == lb ? 0 : la < lb ? -1 : 1; } long long aa[8], aa_[8]; int bb[8], dp[8][1 << (8 - 1)]; char pp[8]; int n, ans = 0x3f3f3f3f; void solve(int i) { i...
// // 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...
/** * 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...
// minako #include <bits/stdc++.h> using namespace std; #define endl n #define f first #define s second #define pb push_back #define pii pair<int,int> #define ll long long #define pll pair <ll,ll> #define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); const ll M = 1e9 + 7; ...
#include <bits/stdc++.h> using namespace std; template <class T> inline void chmax(T &x, T &y) { if (x < y) swap(x, y); } template <class T> inline void chmin(T &x, T &y) { if (x > y) swap(x, y); } const long long INF = 0x3f3f3f3f3f3f; const long long MOD = 1e9 + 7; const double EPS = 10e-10...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int N = 4e2 + 5; int n, f[N][N]; int main() { scanf( %d , &n); f[1][0] = f[1][1] = 1; for (int top = 1; top < n; ++top) { for (int i = 0; i <= n; ++i) { for (int j = 0; j <= n - i + 1; ++j) { int t...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n; cin >> a >> b >> n; a = a * 10; int f = 0; for (int i = 0; i < 10; i++) { if ((a + i) % b == 0) { cout << a + i; string s(n - 1, 0 ); cout << s << endl; f = 1; break; } ...
module shregmap_static_test(input i, clk, output [1:0] q); reg head = 1'b0; reg [3:0] shift1 = 4'b0000; reg [3:0] shift2 = 4'b0000; always @(posedge clk) begin head <= i; shift1 <= {shift1[2:0], head}; shift2 <= {shift2[2:0], head}; end assign q = {shift2[3], shift1[3]}; endmodule module $__SHREG_DFF_P_(...
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003 Matt Ettus // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License...
/* * Copyright (C) 2015 Harmon Instruments, 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 progr...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const int NMAX = 5005; const int INF = 2e5; int n; vector<int> arr; vector<vector<int>> dp(NMAX, vector<int>(NMAX, INF)); int rec(int i, int j) { if (dp[i][j] != INF) return dp[i][j]; if (i == j) return dp[i][j] = 0;...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; t = 1; while (t--) { int n; cin >> n; long long arr[n], c4 = 0, c2 = 0; long long i; map<long long, long long> make_pair; for (i = 0; i < n; i++) { c...
#include <bits/stdc++.h> using namespace std; const long long maxn = 3e5, N = 2e6 + 90, SQ = 300, base = 1999, mod = 1e9 + 7, INF = 1e9 + 1, lg = 30; const long double eps = 1e-4; long long n, a[maxn], b[maxn], c[maxn], d[maxn], cnt[maxn], s1, s2, tot; inline bool check() { for (long lon...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Create Date: 13:11:50 05/24/2012 // Module Name: fifo // Description: fifo buffer // Sourced from: Pong P. Chu, "FPGA Prototyping by Verilog Examples" //////////////////////////////////////////////////...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 02/01/2016 11:58:07 AM // Design Name: // Module Name: FullAdder_NoError // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: ...
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; int main() { string a, v[6]; cin >> a; for (int i = 1; i <= 5; ++i) { cin >> v[i]; if (v[i][0] == a[0] || v[i][1] == a[1]) { cout << YES n ; return 0; } } cout << NO n ; 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; long long power(long long b, long long e, long long m) { long long p = 1; while (e > 0) { if (e & 1) p = (p * b) % m; e = e >> 1; b = (b * b) % m; } return p; } long long cnt[16] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 0}; ...
#include <bits/stdc++.h> using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> */ typedef long long ll; typedef long double ...
/** * 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...
// ============================================================== // 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; string s; cin >> s; vector<int> way(s.size()); way[0] = 0; for (int i = 1; i < (int)s.size(); i++) { if (s[i] == 0 ) way[i] = i; else way[i] = way[i - 1]; } int l = 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...
/** * 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; template <typename T> T nextInt() { T x = 0, p = 1; char ch; do { ch = getchar(); } while (ch <= ); if (ch == - ) { p = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + (ch - 0 ); ch = g...
#include <bits/stdc++.h> using namespace std; void _print(int t) { cerr << t; } void _print(string t) { cerr << t; } void _print(char t) { cerr << t; } void _print(long double t) { cerr << t; } void _print(double t) { cerr << t; } void _print(unsigned long long t) { cerr << t; } template <class T, class...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Mon Jan 23 19:11:23 MST 2017 // Date : Tue Oct 17 02:50:46 2017 // Host : Juice-Laptop running 64-bit major relea...
#include <bits/stdc++.h> using namespace std; char s[100004]; long long k, mod = 1000000007; long long qpow(long long n, long long m) { long long ans = 1; for (; m; m >>= 1) { if (m & 1) ans = ans * n % mod; n = n * n % mod; } return ans; } int main() { scanf( %s %lld , s, &k...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const long long MOD = 1000000000 + 7; const int MAXN = 100000 + 5; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } inline long long readLL() { char ch; bool flag = false; ...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; const long long inf = 199999999999999999; const long long mod = 1e9 + 7; void read() { freopen( lifeguards.in , r , stdin); freopen( lifeguards.out , w , stdout); } void solve() { int coloured[N] = {}, pp[N] = {}, mx ...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 10, M = 1e9, eps = 1e-7, MOD = 1e9 + 7; long long tab[N]; int main() { long long n, l; cin >> n >> l; n--; for (long long i = 1; i <= n; i++) cin >> tab[i]; long long pocz = 0; long long pot = 1 << 30; while (pot...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; int Log[N], bin[21], ls[N], rs[N], root, a[N], n, i, j; set<int> s[N]; pair<int, int> mx[N][20]; long long ans; void merge(int x, int y) { if (s[x].size() < s[y].size()) swap(s[x], s[y]); for (auto& z : s[y]) s[x].insert(z); ...
// Copyright (c) 2000-2011 Bluespec, Inc. // 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, publ...
// ******************************************************************************* // // ** General Information ** // // ******************************************************************************* // // ** Module : firdecim.v ...
/* * 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 a[1000005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int i, j, k, l, m, n, t, r, cnt; int flag = 0; long long ans = 0, an = 0; t = 1; while (t--) { cin >> n >> m; cout << min(n, m) + 1 << e...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: fifo_64_16.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ================================...
#include <bits/stdc++.h> using namespace std; class Solution { public: long long maximize(vector<int>& nums, int x) { int n = nums.size(); vector<vector<long long>> dp(3, vector<long long>(n + 1, 0)); long long res = 0; for (int i = 0; i < n; ++i) { long long num = nums[i]; ...
#include <bits/stdc++.h> using namespace std; const int tinf = (int)1e9 + 7; const long long inf = (long long)1e18 + 7; const int N = 1e5 + 5; long long n, x[10000], y[10000], ans; int main() { { ios ::sync_with_stdio(false); cin.tie(0); } cin >> n; for (int i = 0; i < n; i++) ci...
module top; /*AUTOLOGIC*/ // Beginning of automatic wires (for undeclared instantiated-module outputs) logic sig1; // From u_x of x.v logic [A-1:0] sig2; // From u_x of x.v logic [A-1:0] [B-1:0] sig3; // From u_x of x.v logic [A-1:0][B-...
//Legal Notice: (C)2019 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...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: audio_fifo.v // Megafunction Name(s): // dcfifo // // Simulation Library Files(s): // altera_mf // ============================================...
/** * 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; map<string, int> mapp; int mina = 10000000, minb = 10000000, minc = 10000000, minab = 10000000, minac = 10000000, minbc = 10000000, min3 = 10000000; int x; string na; for (int i = 0; i < n; i++) { c...
#include <bits/stdc++.h> using namespace std; map<char, char> q; int main() { char a[30], b[30]; scanf( %s , a); scanf( %s , b); q.clear(); for (int i = 0; i < 26; i++) { q[a[i]] = b[i]; q[a[i] - 32] = b[i] - 32; } char aim[2000]; scanf( %s , aim); for (int i = 0; a...
// DESCRIPTION: Verilator: Dotted reference that uses another dotted reference // as the select expression // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2020 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 package Pkg; localparam PKG_PARAM = 1; endpackage package Pkg...
/** * 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...
`default_nettype none module reset_test_gate (clk, reset, ctrl, din, sel, dout); input wire clk; input wire reset; input wire [4:0] ctrl; input wire [1:0] din; input wire [0:0] sel; output reg [31:0] dout; reg [1:0] i; wire [0:0] rval; assign rval = {reset, 1'b0 }; always @(pos...
#include <bits/stdc++.h> using namespace std; constexpr long long N = 600500; constexpr long long D = 2000010; constexpr long double EPS = 1e-8; ofstream fout; ifstream fin; int flag = -1; long long n, m, k; vector<vector<int> > v; vector<int> h; vector<int> was; bool comp(int a, int b) { return...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long p, k; cin >> p >> k; long long d = (k - p) / k; if ((((k - p) % k) + k) % k == 0 || (d <= 0 && p > k)) d--; vector<long long> res; res.push_back(d); if (k > p) return co...
`timescale 1ns / 1ns ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 12/06/2013 06:51:42 PM // Design Name: // Module Name: main // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revis...
/** * 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; int N, A, B, X, Ans = 0, C = 0; int main() { cin >> N >> A >> B; for (int i = 1; i <= N; i++) { cin >> X; if (X == 1) { if (A > 0) A--; else if (B > 0) C++, B--; else if (C > 0) C--; els...
#include <bits/stdc++.h> const int N = 60; const int M = 11; const int MOD = 1e9 + 7; int binom[N + 1][N + 1], n, a[N], parent[N], inDegree[N], v0[N], v1[N], msk1[N], dp[N + 1][1 << M]; int findRoot(int u) { if (parent[u] != u) { parent[u] = findRoot(parent[u]); } return parent[u]; }...
//Legal Notice: (C)2012 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 associate...
/* * 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 long long MAXN = 1e2 + 7; long long p[MAXN], dp[MAXN]; pair<long long, long long> fig[MAXN]; int32_t main() { long long n; cin >> n; for (long long i = 0; i < n; ++i) cin >> fig[i].second >> fig[i].first; sort(fig, fig + n); long long t; ...
`timescale 1 ns / 1 ns ////////////////////////////////////////////////////////////////////////////////// // Company: Rehkopf // Engineer: Rehkopf // // Create Date: 01:13:46 05/09/2009 // Design Name: // Module Name: address // Project Name: // Target Devices: // Tool versions: // Description: Address logic w/ S...
// $Id: rtr_next_hop_addr.v 5188 2012-08-30 00:31:31Z dub $ /* Copyright (c) 2007-2012, Trustees of The Leland Stanford Junior University All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistribu...
#include <bits/stdc++.h> using namespace std; double x[1010], y[1010]; bool vis[1010]; int main() { int n, cnt = 0; double x0, y0; scanf( %d%lf%lf , &n, &x0, &y0); for (int i = 0; i < n; i++) { scanf( %lf%lf , &x[i], &y[i]); } for (int i = 0; i < n; i++) { double x1 = x[i], y...
#include <bits/stdc++.h> using namespace std; void main0(); int main() { clock_t start, end; ios::sync_with_stdio(false); cin.tie(0); main0(); return 0; } const int dx[8] = {0, 1, -1, 0, 1, 1, -1, -1}; const int dy[8] = {1, 0, 0, -1, 1, -1, -1, 1}; const int N = 5e5 + 5; const int M ...
/** * 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 limN = 2e5 + 5; char s[limN]; char arr[2000]; int bu[400]; int main() { int t; scanf( %d , &t); for (int i = 0; i < t; i++) { scanf( %s , s); for (int j = 0; j < 2000; j++) arr[j] = . ; for (int j = 0; j < 400; j++) bu[j]...
#include <bits/stdc++.h> using std::string; using std::vector; namespace Template { struct IN { template <class T> void fr(T& a) { T s = 0; int w = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (c...
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { return x > 0 ? x : -x; } int m; int n; map<int, int> id; int rev[100500]; int a[2]; int w[100500], ans[100500]; set<int> s; set<int> ss; void go(int x) { w[x] = 1; x = rev[x]; s.insert(x); for (in...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2014 by Wilson Snyder. // bug823 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; // Take CRC data and app...
#include <bits/stdc++.h> using namespace std; char s[100005]; int main() { int n; scanf( %d , &n); scanf( %s , s); s[n] = # ; for (int i = 0; i < n; i++) { if (s[i] == a || s[i] == e || s[i] == i || s[i] == o || s[i] == u || s[i] == y ) { if (s[i] == e || ...
/* * Decoder for x86 memory access registers * Copyright (C) 2010 Zeus Gomez Marmolejo <> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundati...
/***************************************************************************** * File : processing_system7_bfm_v2_0_arb_wr.v * * Date : 2012-11 * * Description : Module that arbitrates between 2 write requests from 2 ports. * *****************************************************************************/ module ...
/* Text Mode Memory Screen Memory is 16kB, and is organized into 128-bit cells. Also has a 2kB fixed font. */ module ModTxtMemW(clock, reset, pixCellIx, cellData, fontGlyph, fontData, busAddr, busData, busOE, busWR, busOK); /* verilator lint_off UNUSED */ input clock; input reset; input[13:0] pixCellIx; outpu...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2005 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc; initial cyc = 0; reg [63...
#include <bits/stdc++.h> const int MAXN = 100005; int n; char s[MAXN]; int B = 0, R = 0; int main() { while (scanf( %d , &n) != EOF) { scanf( %s , s); int res = 0; B = 0, R = 0; char pre; for (int i = 0; i < n; i++) { if (i == 0) { pre = s[0]; cont...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; long long po[1000006]; long long sr[1000006]; long long a[1000006]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); po[0] = 1; sr[0] = 1; for (int i = 1; i <= 1000002; i++) { po[i] = po[i - 1]...
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize( Ofast ) #pragma GCC optimize( inline ) #pragma GCC optimize( -fgcse ) #pragma GCC optimize( -fgcse-lm ) #pragma GCC optimize( -fipa-sra ) #pragma GCC optimize( -ftree-pre ) #pragma GCC optimize( -ftree-vrp )...
#include <bits/stdc++.h> using namespace std; using lint = long long int; constexpr int MOD = 1000000007; int main() { int T; cin >> T; for (int t = (0), t_end_ = (T); t < t_end_; t++) { int r, c, k; cin >> r >> c >> k; vector<string> map(r); for (int i = (0), i_end_ = (r); i...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const double pi = acos(-1.0); struct Q { int a, b, c; Q(int a, int b, int c) : a(a), b(b), c(c) {} bool operator<(const Q& o) const { if (a == o.a) return c < o.c; return a < o.a; } }; vector<pair<int, int> > ...
#include <bits/stdc++.h> using namespace std; const double h = 1e-6; const int MAX_ = 200005; inline long long int mul(long long int a, long long int b) { return (a * 1ll * b) % 1000000007; } inline long long int sub(long long int a, long long int b) { long long int c = a - b; if (c < 0) c += 10...
#include <bits/stdc++.h> using namespace std; int main() { int a, c, b, v, d, l, n; cin >> a >> b >> c; v = c / (b * 2); n = c % (b * 2); if (n > 0) { v += 1; } l = n / 2 + n % 2; if (l == 0) { l = b; } if (c % 2 == 0) { cout << v << << l << << R ; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, t, a = 0, b = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> t; if (t == 25) a++; else if (t == 50) { b++; a--; if (a < 0 || b < 0) { cout << NO << endl; 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...
/* * 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 (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,...
#include <bits/stdc++.h> using namespace std; using vl = vector<long long>; using vpl = vector<pair<long long, long long>>; using vs = vector<string>; using pl = pair<long long, long long>; using ll = long long int; using vb = vector<bool>; void printcase(ll x) { cout << Case # << x << : ; } void ...
module alu_datapath(clk, alu_data, opcode_value, store_a, store_b, start, alu_done, result, overflow_def); parameter DATA_WIDTH = 8; input clk; input alu_data; input opcode_value; input store_a; input store_b; input start; output alu_done; output result; output overflow_def; reg overflow_def; wire clk; wire [DATA_...
#include <bits/stdc++.h> using namespace std; long long n, m, l, r; vector<long long> A[200001]; set<pair<int, int> > se; void add(long long y) { for (auto b : A[y]) se.insert({b, y}); } void del(long long y) { for (auto b : A[y]) se.erase({b, y}); } int main() { ios_base::sync_with_stdio(...
//IEEE Floating Point to Integer Converter (Single Precision) //Copyright (C) Jonathan P Dawson 2013 //2013-12-12 module float_to_int( input_a, input_a_stb, output_z_ack, clk, rst, output_z, output_z_stb, input_a_ack); input clk; input rst; ...
`timescale 1ns/1ns module usb_rx_sie (input c, input c_48, input oe, input vp, input vm, output [7:0] d, output dv); wire bit_d, bit_dv; wire eop; usb_rx_nrzi rx_nrzi_inst (.c_48(c_48), .vp(vp), .vm(vm), .oe(oe), .d(bit_d), .dv(bit_dv), .eop(eop)); // todo: state machine to parse out the bytes and figure out w...
#include <bits/stdc++.h> using namespace std; int sol = (int)1e9 + 7; int op, lim; int ask(int r, int c) { op++; if (op == lim) { cout << ! << sol << endl; exit(0); } cout << ? << r << << c << endl; int x; cin >> x; sol = min(sol, x); return x; } int go ...
// // ICBLBC functions // // Copyright (c) 2013-2014 Dominic Spill // // This file is part of Unambiguous Encapsulation. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, o...
/* * 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...