text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; template <typename T> void out(T x) { cout << x << endl; exit(0); } void relax(int &x, int y) { x = max(x, y); } const int inf = 1e9; int n, k; int dp[20][1 << 18][2][2]; int like[1 << 18]; int main() { ios_base::sync_with_stdio(false); c...
/** * A module for doing multiplication split across multiple * clock cycles. * * @author Robert Fotino, 2016 */ module multiplier ( input clk, input en, input [BITS-1:0] data_a, input [BITS-1:0] data_b, output reg [(BITS*2)-1:0] result, ...
/** * 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 x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); } return...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; struct node { long long num; int p; } nd[maxn]; long long sum[maxn], f[maxn]; bool cp1(node a, node b) { return a.num < b.num; } int main() { int n, k; ios::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n;...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; string s; cin >> s; bool flag = false; for (int i = 1; i <= n; i++) { if (s[i - 1] == 0 ) { if (i...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
// file: clock_divider.v // // (c) Copyright 2008 - 2013 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is no...
#include <bits/stdc++.h> using namespace std; struct st { long long kici, san; long long kici2, san2; }; long long v[200010]; st T[200010 * 4]; long long t, x, y, q; long long n, k, S, O; void upd(long long pos, long long x, long long l, long long r, long long node) { if (l == r) { v[p...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int main() { int n, K; cin >> n >> K; if (K == 1 || n <= 3) { puts( -1 ); } else if (K >= n) { puts( -1 ); } else if (n == 4) { if (K == 3) { puts( 3 n1 2 n2 3 n3 4 ); } else { puts( -1...
#include <bits/stdc++.h> using namespace std; long long n; const long long maxn = 2e5 + 100; const long long mod = 1e9 + 7; vector<long long> G[maxn]; long long dp[maxn]; long long oth[maxn]; long long fs[maxn], ts[maxn]; long long ans[maxn]; void myinit() { cin >> n; for (long long i = 2; i...
#include <bits/stdc++.h> using namespace std; template <typename T> ostream& operator<<(ostream& os, vector<T>& v) { if (v.size() == 0) { os << empty vector n ; return os; } for (auto element : v) os << element << ; return os; } template <typename T, typename second> ostream&...
#include <bits/stdc++.h> using namespace std; template <class T> inline T mod_v(T num) { if (num >= 0) return num % 1000000007; else return (num % 1000000007 + 1000000007) % 1000000007; } template <class T> inline T gcd(T a, T b) { a = abs(a); b = abs(b); while (b) b ^= a ^= ...
/* * Baseband Processor * * Must read EPC Gen2 UHF RFID protocols * * All of the input and output signals depend on your whole RFID Tag design * In this case, we use the delayed PIE code to clock the received PIE code. So we should input PIE code (pie_code) and delayed PIE code (clk_dpie) * we use the clo...
#include <bits/stdc++.h> using namespace std; const unsigned long long MOD = 4207849484; int main() { int n, m, i, g, h, j; char c; scanf( %d%d , &n, &m); vector<int> a(n + 1, 0), bl(n + 1, 0); for (int(i) = 0; (i) < (m); ++(i)) { getchar(); scanf( %c %d , &c, &g); if (c == ...
module timer( input CLK, input switch_up, input switch_dn, input switch_cancel, input switch_start_stop, output [7:0] SEG, output [3:0] DIGIT, output BUZZER ); wire s_up, s_dn, s_cancel, s_start_stop; debouncer d1(.CLK (CLK), .switch_input (switch_up), .trans_dn (s_up)...
/* * Copyright (c) 2015, Ziliang Guo * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of cond...
#include <bits/stdc++.h> using namespace std; int N, s1, s2; int data[100001]; bool isRange(int x, int y, int z) { if (z >= x && z <= y) return true; return false; } int check(int x) { int L = data[N] - x; int R = data[N] + x; for (int i = N - 1; i >= 1; i--) { if (isRange(L, R, da...
#include <bits/stdc++.h> using namespace std; using ll = long long; int const nmax = 3000; int const modulo = 1000000007; char v[1 + nmax][1 + nmax]; int dp[1 + nmax][1 + nmax]; int solve(int x, int y, int x2, int y2) { for (int i = 1; i <= x2; i++) for (int j = 1; j <= y2; j++) dp[i][j] = 0; ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 9, M = 3e5 + 9, OO = 0x3f3f3f3f; const double EPS = 0.00000000001; const int mod = 1000003; int n, m, d[3005]; bool flage = 1; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < m; ++i) { scanf( %d , d + i); if (d[i...
// Spartan 3A DSP and Spartan 6 block RAM mapping (Spartan 6 is a superset of // Spartan 3A DSP). module \$__XILINX_RAMB8BWER_SDP (CLK2, CLK3, A1ADDR, A1DATA, A1EN, B1ADDR, B1DATA, B1EN); parameter CLKPOL2 = 1; parameter CLKPOL3 = 1; parameter [9215:0] INIT = 9216'bx; input CLK2; input CLK3; input [7:0] A1ADDR...
/* * 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 maxn = 2e5 + 10; const int mod = 1e9 + 7; int n; struct block { vector<int> v; int id; }; vector<block> b; int a[maxn]; void get_blocks() { b.clear(); block cur; int j = 1; while (j <= n) { cur.v.clear(); while...
#include <bits/stdc++.h> const int N = 1e3 + 5; int n, m, q, sum[N][N]; int opt(int x, int y) { return (__builtin_popcount(x) + __builtin_popcount(y)) & 1; } int calc(int x, int y, int opt) { return opt == 0 ? sum[x][y] : x * y - sum[x][y]; } long long I(int x, int y, int r, int c) { long long...
// ZX-Evo Base Configuration (c) NedoPC 2008,2009,2010,2011,2012,2013,2014 // // renders fetched video data to the pixels /* This file is part of ZX-Evo Base Configuration firmware. ZX-Evo Base Configuration firmware is free software: you can redistribute it and/or modify it under the terms of ...
/* * 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() { long long n, k, i, l; cin >> n >> k; string s; cin >> s; long long max = 0; for (i = 1; i < n; i++) { long long temp = 0; for (l = 0; l < n; l++) { if (i + l < n) { if (s[i + l] == s[l]) { te...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000000 + 2; const long long MOD = 1e9 + 7; int N, p[MAXN]; long long s[MAXN], c[MAXN], f[MAXN], Ans; long long gcd(long long a, long long b) { if (a < b) swap(a, b); return b ? gcd(b, a % b) : a; } int main() { cin >> N; for...
// megafunction wizard: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: dcfifo // ============================================================ // File Name: fifo_57x64.v // Megafunction Name(s): // dcfifo // // Simulation Library Files(s): // altera_mf // ============================================...
// (C) 1992-2014 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 simulati...
module ISP1362_IF( // avalon MM slave port, ISP1362, host control // avalon MM slave, hc interface to nios avs_hc_writedata_iDATA, avs_hc_readdata_oDATA, avs_hc_address_iADDR, avs_hc_read_n_iRD_N, avs_hc_write_n_iWR_N, avs_hc_chipselect_n_iCS_N, avs_hc_reset_n_iRST_N, avs_hc...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; char c = a ; for (int i = 0; i < s.size(); i++) { if (s[i] == z + 1) continue; else if (s[i] != c) { cout << NO n ; return 0; } else { for (int j = i; j < s.size(); j+...
#include <bits/stdc++.h> using namespace std; long long int mod_Expo(long long int x, long long int n, long long int M) { if (x == 0) return 0; if (n == 0) return 1; else if (n % 2 == 0) return mod_Expo((x * x) % M, n / 2, M); else return (x * mod_Expo((x * x) % M, (n - 1) / 2, M))...
module var20_multi (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, valid); input A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T; output valid; wire [8:0] min_value = 9'd120; wire [8:0] max_weight = 9'd60; wire [8:0] max_volume = 9'd60; wire [8:0] total_value = A ...
#include<bits/stdc++.h> #define ll long long #define L(i, j, k) for(int i = (j); i <= (k); ++i) #define R(i, j, k) for(int i = (j); i >= (k); --i) #define vi vector < int > #define sz(a) ((int) a.size()) using namespace std; const int N = 1e6 + 7; int T; int n, m, c[N], a[N], b[N]; void Main (...
#include <bits/stdc++.h> using namespace std; const int MX = (int)1e6 + 17; const int MOD = (int)1e9 + 7; const long long oo = (long long)1e18 + 7; const int INF = (int)999999999; const int N = (int)1e5 + 17; const int di[4] = {-1, 0, 1, 0}; const int dj[4] = {0, 1, 0, -1}; inline long long IN() { ...
#include <bits/stdc++.h> using namespace std; int a[1000005]; int main() { int n, m; while (~scanf( %d%d , &n, &m)) { if (n == 1) { printf( YES n%d n , m); } else if (n == 2) { if (m == 0) { printf( NO n ); } else { printf( YES n0 %d n , m); ...
//Legal Notice: (C)2018 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...
// Oversampling UART receiver. module UART_RX( input rst, clk, baud_edge, rx, output [7:0] data, output data_ready, framing_error ); parameter OVERSAMPLE = 8; localparam FIND_EDGE = 3'd1, START = 3'd2, DATA = 3'd3, END = 3'd4; reg prev_rx; reg [7:0] data_reg; reg [2:0] data_counter; ...
#include <bits/stdc++.h> using namespace std; int main() { long a[5], b[5], n, cu, medal, x, y; cin >> a[1] >> a[2] >> a[3]; cu = a[1] + a[2] + a[3]; cin >> b[1] >> b[2] >> b[3]; medal = b[1] + b[2] + b[3]; cin >> n; if (cu % 5 == 0) x = cu / 5; else x = cu / 5 + 1; i...
//Legal Notice: (C)2010 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; int arr[100005]; long long sum[100005]; map<int, long long> f; long long solve(int n, int k) { if (f.count(k)) return f[k]; long long ret = 0; long long cur = n - 2; long long p = k; while (cur >= 0) { ret += sum[cur]; cur -= p; ...
/** * 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: Test for using DPI as general accessors // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2012. // // Contributed by Jeremy Bennett and Jie Xul // // This test exercises the use of DPI to access signals and registers in a // module hierarchy in a uniform...
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, res = pow(10, 18); cin >> n; vector<long long int> v(n); for (long long int i = 0; i < n; i++) cin >> v[i]; sort(v.begin(), v.end()); for (long long int i = 0; i < n / 2; i++) res = min(res, v[i + n / 2] - v[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, m, a, b, w, start = 0, k; long long int MAX = 1e18; vector<vector<int> > wait(100005); vector<vector<pair<int, int> > > adj(100005); void binarySearch(int v, long long int& d) { if (v == n - 1 or wait[v].size() == 0) { return; } int low ...
// ==================================================================== // Radio-86RK FPGA REPLICA // // Copyright (C) 2011 Dmitry Tselikov // // This core is distributed under modified BSD license. // For complete licensing information see LICENSE.TXT. // -----------------------------...
#include <bits/stdc++.h> const int inf = 0x3f3f3f3f, Inf = 0x7fffffff; const long long INF = 0x7fffffffffffffff; template <typename _Tp> _Tp gcd(const _Tp &a, const _Tp &b) { return (!b) ? a : gcd(b, a % b); } template <typename _Tp> __inline__ __attribute__((always_inline)) _Tp abs(const _Tp &a) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; std::ios::sync_with_stdio(false); cin >> n >> m; int x, y; for (int i = 0; i < m; i++) cin >> x >> y; for (int i = 0; i < n; i++) if (i % 2 == 0) cout << 0; else cout << 1; return 0; }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define ff first #define ss second void solve() { int n; cin>>n; int sum=0; int cnt=1; while(sum<n) { sum+=cnt; cnt+=1; } if(sum-1==n) cout<<cnt; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7; int a[maxn]; int b[maxn]; int n; vector<pair<int, int>> v; void borrow(int pos, int val) { if (val == 1) { if (a[pos + 1] == 0) borrow(pos + 1, -1); if (v.size() >= 100000) return; v.push_back(make_pair(pos, -1))...
module sha1_update( input clk, input start, input [511:0] data_in, input [159:0] hash_state_in, output done, output reg [159:0] hash_state_out ); localparam IDLE = 2'd0; localparam COMPRESSING = 2'd1; localparam DONE = 2'd2; ...
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of inst_t_e // // Generated // by: wig // on: Wed Aug 18 12:44:01 2004 // cmd: H:/work/mix_new/MIX/mix_0.pl -strip -nodelta ../../constant.xls // // !!! Do not edit this file! Autogenerated by MIX !!! ...
/* * 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; char st[1000010]; int n, K; int main() { int i, j; scanf( %d%d , &n, &K); scanf( %s , st + 1); for (i = 1; i < n && K; ++i) if (st[i] == 4 && st[i + 1] == 7 ) { if (i % 2) st[i + 1] = 4 ; else { st[i] = ...
#include <bits/stdc++.h> using namespace std; const int N = 1 << 18; int uf[N]; int cost[N]; vector<pair<int, int>> h_uf; vector<pair<int, int>> h_cost; pair<int, int> query[N]; int ans[N]; bool sample; struct edge { int u, v, w; edge(int u, int v, int w) : u(u), v(v), w(w) {} }; vector<...
//====================================================================== // // tb_blake2.v // ----------- // Testbench for the Blake2 top level wrapper. // // // Copyright (c) 2013, Secworks Sweden AB // All rights reserved. // // Redistribution and use in source and binary forms, with or // without modification, are p...
/** * 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 (C) 2013 Simon Que // // This file is part of DuinoCube. // // DuinoCube is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later ...
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T &x) { x = 0; char c = getchar(); int f = 1; while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) x = x * 10 - 0 + c, c = getchar(); x *= f; } const int N = 1...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long a, f, sec, t = 0, h = 0; cin >> a; vector<long long> par; vector<long long> m; for (int i = 0; i < s.length(); i++) { if (s[i - 1] == s[i]) { h++; } par.push_back(h); } ...
/** * 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...
/** * 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; struct name { int l, r; } bl[200001]; bool cmp(name n, name m) { if (n.r == m.r) return n.l < m.l; return n.r < m.r; } int main() { int n, x, w, ans = 0; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d%d , &x, &w); b...
#include <bits/stdc++.h> using namespace std; const long long Mod = 1000000007; long long fp(long long a, long long k) { long long res = 1; while (k) { if (k & 1) res = res * a % Mod; a = a * a % Mod; k >>= 1; } return res; } int main() { long long n, m; scanf( %I64d%...
/* from bscan_s6_spi_isf.v */ assign CSB = !(CS_GO && !CS_STOP); assign RAM_DI = MISO; assign TDO1 = RAM_DO; wire rst = CAPTURE || RESET || UPDATE || !SEL1; always @(negedge DRCK1 or posedge rst) if (rst) begin have_header <= 0; CS_GO_PREP <= 0; CS_STOP <= 0...
#include <bits/stdc++.h> using namespace std; struct rec { long long w, h, c; } a[200010] = {0}; int n; long long ans; vector<long long> p, sum; double ABS_dec(double x1, double x2) { if (x1 < x2) return x2 - x1; return x1 - x2; } void quick_sort(struct rec a[], long h, long e) { long ...
// Copyright (C) 2013 Simon Que // // This file is part of DuinoCube. // // DuinoCube is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later ...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int x1 = 0, x2 = 0, y1 = 0, y2 = 0, position = 0; int length = s.size(); for (int i = 0; i < length; i++) { if (s[i] == R ) { x1++; position++; } if (s[i] == L ) { x1--; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; char a[maxn], b[maxn]; int pre[maxn], suf[maxn]; int main() { scanf( %s%s , a + 1, b + 1); int n = strlen(a + 1); int m = strlen(b + 1); int pos = 0; for (int i = 1; b[i]; i++, pos++) { while (pos <= n && a[pos] ...
#include <bits/stdc++.h> using namespace std; const int sz = 2e5; int n, k; long long add[sz], cost[sz], pre[sz], suf[sz], mnpre[sz], mnsuf[sz], bestSufTake[sz], bestSufTakeFromPre[sz]; void input() { cin >> n >> k; for (int i = 0; i < n; i++) cin >> add[i]; for (int i = 0; i < n; i++) cin >...
#include <bits/stdc++.h> using namespace std; const long long base = 17LL; const long long MOD = 998244353LL; const int MAXN = 1e5 + 10; struct Node { long long v; long long tagv; long long len; } st[MAXN << 2]; long long a[MAXN]; inline long long fp(long long x, long long y) { long long...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e3 + 5; const int mod = 998244353; char s[maxn], t[maxn]; int m, n, dp[maxn][maxn]; int main() { scanf( %s%s , s + 1, t + 1); n = strlen(s + 1); m = strlen(t + 1); for (int i = 1; i <= n; i++) { if (i > m || t[i] == s[1]) ...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; struct point { double x, y; point(double _x = 0, double _y = 0) : x(_x), y(_y) {} void read() { scanf( %lf%lf , &x, &y); } }; point polygon[30]; int sign(double x) { if (fabs(x) < eps) return 0; return (x > 0) ? 1 : -...
// // Copyright (c) 2014 Jan Adelsbach <>. // 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 Foundation, either version 3 of the License, or // (at your optio...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e4 + 10; const int M = 128; const int inf = 0x7fffffff; const long long INF = 9E18; const int mod = 1e9 + 7; int n, m; int pos[M][maxn], len[M]; int dp[M][maxn]; char s[M][maxn]; int main() { scanf( %d%d , &n, &m); for (int i ...
/* * Copyright (c) 2015-2017 The Ultiparc Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list...
#include <bits/stdc++.h> using namespace std; int n, d[128][128][8]; string s; int main() { ios::sync_with_stdio(0); cin >> n >> s; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) for (int k = 0; k <= 4; k++) { if (s[i - 1] == . ) continue; if (!k) { ...
#include <bits/stdc++.h> using namespace std; const int MAX = 100020; const long long MOD = (int)1e9 + 7; const int INF = 1e9; const long long LLINF = 0x3f3f3f3f3f3f3f3f; const long double EPS = 1e-7; int logv[MAX + 1]; void make_log() { logv[1] = 0; for (int i = 2; i <= MAX; i++) logv[i] = logv...
/* * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law...
#include <bits/stdc++.h> using namespace std; bool DEB = 0; void __start__() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } mt19937_64 rnd(time(0)); using ll = long long; using vi = vector<int>; using ld = long double; using pii = pair<int, int>; void test_case() { ll n, k, tw...
// (C) 1992-2015 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 simulati...
module Lolhi( input A, input B, input C, input AnalogLDir, input AnalogRDir, output Len, output Ldir, output Ren, output Rdir ); wire Z_A; wire Z_B; wire Z_C; wire Ldir_int; wire Len_int; wire Rdir_int; wire Ren_int; wire Analog_select; supply0 GND; assign Analog_select = AnalogLDir & AnalogRD...
/** * 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 alu( output reg [31:0] Z, input [31:0] A, input [31:0] B, input [5:0] ALUFun, input Sign ); wire zero, overflow, negative; wire [31:0] adder_out, comparer_out, logicer_out, shifter_out; adder adder1(.Z (zero), .V (overflow), .N (negative), .dout(...
#include <bits/stdc++.h> using namespace std; int v[300123], n, ans, g[300123], f[300123], a, b, m, op; queue<int> q; int main() { ios_base::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; ++i) { cin >> v[i]; if (~v[i]) g[v[i]]++; else { g[0]++; } } ...
#include <bits/stdc++.h> using namespace std; long long c[110][110]; long long a[110]; long long tmp[110]; long long dp[10][110]; long long gao(long long n) { memset(dp, 0, sizeof(dp)); long long i, j, k; long long m = 0; for (i = 0; i <= 9; i++) m += a[i]; if (m > n) return 0; for (...
#include <bits/stdc++.h> using namespace std; int a[10][5]; int ulx, uly, drx, dry; bool isd(int x, int y) { return x <= drx && x >= ulx && y <= dry && y >= uly; } bool vis[210]; int numtot; int pos; int len; int abs(int x) { return x < 0 ? -x : x; } bool isd2(int x, int y) { return abs(x - a[po...
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, n, x, y, a, ans = 0; cin >> n; int arr[n]; for (i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] > ans) ans = arr[i]; } for (i = 2; i <= n; i++) { for (j = 0; j < n - i + 1; j++) { int a = arr[j];...
#include <bits/stdc++.h> using namespace std; const int sz = 55; int n, r1, c1, r2, c2, ans = 1000000000; string s[sz]; bool visited[sz][sz]; vector<pair<int, int> > v; void dfs(int x, int y, bool flag) { if (x < 1 || x > n || y < 1 || y > n || s[x][y] == 1 || visited[x][y] == true) { ...
#include <bits/stdc++.h> int n; int x[200050]; int f[200050]; int ans = 0; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &x[i]); for (int i = 0; i < n; i++) scanf( %d , &f[i]); int k = 0, l = 0; while (l < n) { if (x[k] == f[l]) k++, l++; else ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2008 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; integer cyc=0; reg [63:0] crc; reg [63:0] sum; /*AUTOWIRE*/ // Beginning of au...
#include <bits/stdc++.h> using namespace std; int book[3]; char s[105], rs[105]; int main() { int t, ans, n; scanf( %d , &t); for (int i = 0; i < t; i++) { scanf( %d , &n); ans = 0; memset(rs, 0 , sizeof(rs)); for (int i = 0; i < 3; i++) { scanf( %d , &book[i]); ...
#include <bits/stdc++.h> using namespace std; int main() { int v_1, v_2, v_3, v_m, m_1, m_2, m_3; cin >> v_1 >> v_2 >> v_3 >> v_m; if (v_m >= v_2 || v_m < v_2 && v_m > v_3 && 2 * v_3 < v_m || v_m <= v_3 && 2 * v_m < v_3) { cout << -1; return 0; } cout << 2 * v_1 << n << 2 ...
// // Designed by Qiang Wu // `timescale 1ns/1ps `include "NF_2.1_defines.v" `include "registers.v" `include "reg_defines_reference_router.v" module packet_buffer_bypass( input clk, input reset, output [239:0] TRIG0, input [63:0] in_data, input [23:0] in_pkt_route, input in_wr, output reg in_empty,...
#include <bits/stdc++.h> using namespace std; int n, ans[1010][1010]; pair<int, int> a[1010]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i].first), a[i].second = i; sort(a + 1, a + n + 1); for (int i = 1; i <= n; i++) { int j = i; while (a[i].first--) a...
#include <bits/stdc++.h> using namespace std; const int N = 200035; long long a[N]; long long b[N]; long long c[N]; const long long INF = 1e17; bool can[N]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n, k; cin >> n >> k; ++n; for (int i = 0; i < n; ++i) c...
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; long long power(long long x, unsigned long long y) { long long res = 1; while (y > 0) { if (y & 1) { res = res * x; } y = y >> 1; x = x * x; } return res; } long long powermod(long long x...