text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int b[111111], n; int check(int k) { int l = n / k; for (int i = 0; i < l; i++) { int ok = 1; int cur = i; for (int j = 0; ok && j < k; j++) { if (!b[cur]) ok = 0; cur += l; cur %= n; } if (ok) return 1; ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 19:33:57 04/26/2017 // Design Name: decrypter // Module Name: C:/Users/vkoro/Final_Project/project/vga/decrypt_manager_tb.v // Project Name: vga // Target ...
/** * 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 <class T> void chkmax(T& x, T y) { x = x > y ? x : y; } template <class T> void chkmin(T& x, T y) { x = x < y ? x : y; } int n, m; vector<string> s; int calc(int mask, int j) { int res = 0; for (int i = 0; i < n; ++i) 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 la...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; int n, l[100100], r[100100]; int rs[100100], dp[2][100100]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> l[i]; for (int i = 1; i <= n; i++) cin ...
#include <bits/stdc++.h> bool g[1111][1111]; int main() { int n, m; memset(g, false, sizeof(g)); scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { int u, v; scanf( %d%d , &u, &v); g[u][v] = true; } int count = 0; for (int i = 2; i < n; i++) { bool flag = false;...
#include <bits/stdc++.h> using namespace std; const long long int N = 200005; const long long int mod = 1e9 + 7; long long int n, i, j, m, k; long long int a[N]; long long int sz[N], c[N]; long long int vis[N]; vector<long long int> g[N]; long long int ans = 0; void dfs(long long int v, long long in...
#include <bits/stdc++.h> using namespace std; int N, Q; vector<vector<int> > adj; vector<set<int> > grp; vector<int> dep, tin, tout; vector<vector<int> > par; int num = 0; void dfs(int now, int bf) { tin[now] = num++; if (bf != -1) par[now][0] = bf; for (int i = 1; i < 18; i++) { int t...
`include "alink_define.v" module txc( input clk , input rst , input reg_flush , input [`PHY_NUM-1:0] reg_mask , input task_id_vld , input [31:0] reg_tout , input tx_task_vld ,//tx fif...
module phyInital ( input clk,reset, input iniStart, input [3:0]ram_read_addr, input [31:0] command, input [15:0]command_and, inout md_inout, output mdc, output reg [3: 0] comm_addr, output reg iniEnd, output reg [12:0]stateout, ...
/* * 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() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long int n; cin >> n; long long int a[n]; map<long long int, long long int> mp; for (long long int i = 0; i < n; i++) { cin >> a[i]; mp[a[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, x, sum, ans, a; int main() { scanf( %d %d , &n, &x); for (int i = 0; i < n; i++) { scanf( %d , &a); sum += a; } sum = abs(sum); ans = (sum / x) + (sum % x != 0); printf( %d n , ans); return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { map<char, long long> m; for (long long i = 0; i < 26; i++) { char ch; cin >> ch; m[ch] = i; } string str; cin >> str; long long ans = 0, sum = 0; for (long long i = 0; i < str.length() - 1; i++) { sum = ...
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > a[100500]; int d[100500]; int main() { int n, m, cap; scanf( %d%d%d , &n, &m, &cap); cap--; for (int i = 0; i < (m); i++) { int x, y, w; scanf( %d%d%d , &x, &y, &w); x--, y--; a[x].push_back(pair<int, i...
#include <bits/stdc++.h> using namespace std; vector<int> _edge; set<int> se, to_del; int main() { ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); int t, n, m, i, j, k, x, y, z, a, b, c; cin >> t; while (t--) { cin >> n >> m; n *= 3; se.clear(); _edge.c...
/** * 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...
#include <bits/stdc++.h> using namespace std; int main() { int n, a, od = 0, ev = 0, ans = 0; cin >> n; vector<int> vec; vector<int>::iterator it; while (n--) { cin >> a; vec.push_back(a); if (a % 2 == 0) ev++; else od++; } for (it = vec.begin(); i...
// megafunction wizard: %RAM: 2-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: dpram_32_32x16_be.v // Megafunction Name(s): // altsyncram // ============================================================...
#include <bits/stdc++.h> using namespace std; int n; int a[101101]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); sort(a, a + n); int l = 0, r = n - 1, ans = 0; for (int i = 0; i < n; i++) { if (a[l] < a[i]) { ans++; l++; } else ...
/* Copyright (c) 2015-2018 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, distri...
/************************************************************************ fx3StateMachine.v FX3 State-Machine module Domesday Duplicator - LaserDisc RF sampler Copyright (C) 2018 Simon Inns This file is part of Domesday Duplicator. Domesday Duplicator is free software: you can redistribute it and/or modi...
#include <bits/stdc++.h> using namespace std; const int shape[4][4][2] = {{{1, 0}, {2, 0}, {1, 1}, {1, 2}}, {{1, 0}, {2, 0}, {2, -1}, {2, 1}}, {{0, 1}, {0, 2}, {-1, 2}, {1, 2}}, {{0, 1}, {0, 2}, {1, 1}, {2, 1}}}; int x, y; ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; pair<long long, long long> res; long long a[N]; void dfs(long long cur, long long cnt, long long sum) { if (!cur) { res = max(res, {cnt, sum}); return; } else { int p = upper_bound(a + 1, a + N, cur) - a; --p;...
#include <bits/stdc++.h> using namespace std; const long long maxn = 2e5 + 15; inline long long read() { long long x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = (x << 1) + (x << 3) + c ...
/** * 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 / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 03/29/2016 05:57:16 AM // Design Name: // Module Name: Testbench_FPU_Add_Subt // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // /...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 02/19/2016 08:12:53 AM // Design Name: // Module Name: D_Register // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; int c = 2 * min(a, b); int d = max(a, b); if (c > max(a, b)) { cout << c * c << endl; } else { cout << d * d << endl; } } r...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using i3 = pair<int, ii>; using li = pair<ll, int>; using lii = pair<ll, ii>; using vi = vector<int>; using vl = vector<ll>; using vli = vector<li>; using vii = vector<ii>; using vi3 = vector<i3>; usin...
#include <bits/stdc++.h> using namespace std; struct node { int l, r, x, y; }; vector<node> p[500010]; int a[500010], b[500010], c[500010]; int main() { int i, j, k, n, m, s; node e; scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) scanf( %d , &a[i]); b[0] = 0; for (i = 1; i <= n ...
#include <bits/stdc++.h> using namespace std; const int B = 31; const int N = 107; int a[N]; bool vis[1000007]; map<int, int> state; map<int, int> sgn; int tc = -1; inline int grrr(int mask) { if (mask < 2) return 0; auto it = sgn.find(mask); if (it != sgn.end()) return it->second; vec...
#include <bits/stdc++.h> using namespace std; #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) const long long INFll = 1e18; const int INFint = 1e9; const long long MOD = 1e9 + 7; void needForSpeed() { ios_base::sync_with_stdio(0); cin.tie(0); ...
// (C) 2001-2016 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 doc...
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; char c = getchar(); T sig = 1; for (; !isdigit(c); c = getchar()) if (c == - ) sig = -1; for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - 0 ; x *= sig; } class Solution {...
#include <bits/stdc++.h> const bool debugging = 1; const long long mod = 1e9 + 7; using namespace std; template <class T> ostream &operator<<(ostream &os, vector<T> V) { for (auto v : V) { os << v << ; } return os << ; } template <class T> ostream &operator<<(ostream &os, vector<v...
#include <bits/stdc++.h> int n, m, f, c[150005], p, a, b; long long A; struct odp { long long L, M, R, S; odp() {} odp(long long L, long long M, long long R, long long S) : L(L), M(M), R(R), S(S) {} } t[150005 * 4]; void init(int n, int l, int r) { if (l == r) t[n].L = t[n].R = t...
//////////////////////////////////////////////////////////////////////////////////////////////////// // 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, or (at...
module BigSDRAM(clock0,clock180,clock270,reset,leds,ddr_clock0,ddr_clock90,ddr_clock270,ddr_cke,ddr_csn,ddr_rasn,ddr_casn,ddr_wen,ddr_ba,ddr_addr,ddr_dm,ddr_dq,ddr_dqs); input wire clock0; input wire clock180; input wire clock270; input wire reset; output wire [7:0] leds...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, l, k; cin >> n >> l >> k; vector<int> cnt(26, 0); for (int i = 0; i < n * l; ++i) { char c; cin >> c; cnt[c - a ]++; } int last = 0; ...
#include <bits/stdc++.h> using namespace std; const long long N = 5 * 1e5 + 1; long long n, a[N], sum[N], s, f, ans; int32_t main() { ios_base ::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (long long i = 0; i < n; i++) { cin >> a[i]; if (i) sum[i] = sum...
#include <bits/stdc++.h> template <class T> inline T lowbit(T x) { return x & (-x); } template <class T> inline T sqr(T x) { return x * x; } template <class T> inline bool scan(T &ret) { char c; int sgn; if (c = getchar(), c == EOF) return 0; while (c != - && (c < 0 || c > 9...
//////////////////////////////////////////////////////////////////////////////// // // Filename: wbarbiter.v // // Project: Zip CPU -- a small, lightweight, RISC CPU soft core // // Purpose: At some point in time, I might wish to have two masters connect // to the same wishbone bus. As an example, I might wish to ha...
#include <bits/stdc++.h> using namespace std; struct node { char name[55]; int score; int c[50]; } comp[55]; int cmp1(node x, node y) { if (x.score > y.score) return 1; else if (x.score == y.score) { for (int i = 0; i < 50; i++) if (x.c[i] > y.c[i]) return 1; ...
#include <bits/stdc++.h> using namespace std; int x, y, n, m, i, k, ans; string s[30], s1[30]; int main() { cin >> n >> m; for (i = 0; i < n; i++) { cin >> s[i]; } for (i = 0; i < m; i++) { cin >> s1[i]; } cin >> k; for (i = 0; i < k; i++) { cin >> x; if (x % ...
/* Copyright (c) 2019 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; const int N = 55; const int d[4][2] = {-1, 0, 0, 1, 1, 0, 0, -1}; char a[N][N]; int v[4][N][N][2], m, n; int q[N * N * 4 * 2][4]; int check(int x, int y) { if (x >= 1 && x <= m && y >= 1 && y <= n && a[x][y] == B ) return 1; else return 0;...
////////////////////////////////////////////////////////////////////// //// //// //// uart_tfifo.v //// //// //// //// ...
/* Distributed under the MIT license. Copyright (c) 2016 Dave McCoy () 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, mo...
//% @file adc_cnv_sipo.v //% @brief Drive ADC (LTC2325-16) conversion and convert Serial dataIn to Parallel dataOut. //% @author Yuan Mei //% //% @param[in] NCH total number of ADC channels //% //% Relative time (phase) relation between cnv_n and clkff is //% critical. One can swap D1, D2 bits in ODDR to achieve half-...
#include <bits/stdc++.h> using namespace std; const int M = 3e5 + 10; const long long inf = 1e18 + 10; const long long mod = 1e1; long long a[M], p[M], dp[3][M]; int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); for (int i = 0; i <= n; i++) dp[0][i] = d...
// ---------------------------- // This module impelements a scanflop. // // Note: // - Syntax works and compiles with Verilog2LPN compiler // - async. design follows dual rail encoding that maps // input to output and output to internal states // // author: Tramy Nguyen // ---------------------------- module scanf...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, x, y, z; cin >> a >> b >> c; cin >> x >> y >> z; a -= x; b -= y; c -= z; if (a >= 0) a /= 2; if (b >= 0) b /= 2; if (c >= 0) c /= 2; if (a + b + c >= 0) cout << Yes << endl; else cout <<...
#include <bits/stdc++.h> using namespace std; double const e = 0.000001; int main() { int n, a, d; cin >> n >> a >> d; int prevv = 10000000; double prevt = 0; for (int i = 0; i < n; i++) { int t, v; cin >> t >> v; double t1 = (double)v / a; double s1 = a * t1 * t1 / 2; ...
#include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int main() { fast; int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n + 1); a[0] = 0; for (int i = 1;...
// // (c) Copyright 2010 - 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. /...
#include <bits/stdc++.h> using namespace std; int a[51]; int b[51]; int d1[51]; int d2[51]; int main() { int n, l; int i, j, k; cin >> n >> l; for (i = 1; i <= n; i++) { cin >> a[i]; if (i >= 2) d1[i] = a[i] - a[i - 1]; } d1[1] = a[1] + l - a[n]; for (i = 1; i <= n; i...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m, k; cin >> n >> m >> k; vector<vector<int> > g(n); vector<int> deg(n); for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; --x; --y; ...
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9; const int mod = (int)1e9 + 7; const int MAXN = (int)3e5 + 5; vector<int> primes[1000005]; int x, p, k; vector<pair<int, int> > v(1 << 7); int calc(int a) { int cnt = 1; int num = 0; int tmp = a; a = 0; for (int i...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); ; unsigned long long x, y; cin >> x >> y; if (x < y) { return cout << -1, 0; } if ((x - y) & 1) { return cout << -1, 0; } long long z = (x -...
module Rx(CLK,reset,cableReset_L,hardReset_L, message_received_for_Phy, CC_Busy, CC_Idle, Start, Unexpected_goodCRC, Tx_state_Machine, Data_from_I2C, Tx_Message_Discarded,ALERT,RECEIVE_BYTE_COUNT, GoodCRCtoPhy, address, DataToReg); localparam Rx_Idle = 4'b0000; localparam Rx_Wait_For_Phy_Message = 4'b0001; localparam...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; const int inf = 0x3f3f3f3f; int t, n; int a[200]; int main() { int n, q, t, k, d; int cnt; int sum; memset(a, 0, sizeof a); cin >> n >> q; for (int i = 0; i < q; i++) { cnt = 0; sum = 0; cin >> ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long int> dis(n); vector<long long int> ans(n); vector<bool> vis(n, 0); long long int acc = 0; for (long int i = 0; i < n; i++) { cin >> dis[i]; acc += dis[i]; } vector<vector<int>...
module fmrv32im_BADMEM_sel ( // Data Memory Bus output D_MEM_WAIT, input D_MEM_ENA, input [3:0] D_MEM_WSTB, input [31:0] D_MEM_ADDR, input [31:0] D_MEM_WDATA, output [31:0] D_MEM_RDATA, output D_MEM_BADMEM_EXCPT, // DMEM input C_MEM_WAIT, output ...
#include <bits/stdc++.h> using namespace std; struct __s { __s() { if (1) { ios_base::Init i; cin.sync_with_stdio(0); cin.tie(0); } } ~__s() { if (!1) fprintf(stderr, Execution time: %.3lf s. n , (double)clock() / CLOCKS_PER_SEC); ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; long long int prices[n]; for (long long int i = 0; i < n; i++) { cin >> prices[i]; } long long int minimum = prices[0]; long long int ans = 0; for (long long int i = 1; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; const int MOD = 1000000007; unordered_map<int, bool> sp; vector<int> g[MAX]; struct node { int u, v; int cost; node(int _u, int _v, int _cost) { u = _u; v = _v; cost = _cost; } }; bool mst_sort(node &...
/** * 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: %FIFO% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: cpci_pci2net_16x60.v // Megafunction Name(s): // scfifo // // Simulation Library Files(s): // altera_mf // ========================...
`ifndef INCLUDE_PARAMS `include "params.v" `endif //Data Memory module DMem( input wire rst_n, input wire [`WIDTH - 1:0] add, inout wire [`WIDTH - 1:0] data, input wire wr, input wire rd, output reg rd_st, input wire [1:0] mode //mode: 0-word, 1-halfword, 2-byte // mem trace `ifdef TRACE_MEM ,input wire Prin...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int len, k; cin >> len >> k; string s; cin >> s; sort(s.begin(), s.end()); if (s[0] != s[k - 1]) cout << s[k - 1] << endl; else { cout << s[k - 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...
/** * 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 gcd(int a, int b) { if (a % b == 0) return b; return gcd(b, a % b); } int v[11]; int main() { int a, k = 0; scanf( %d , &a); for (int i = 2; i < a; i++) { int t = a; int pos = 0; while (t) { int mod = t % i; ...
// Listing 5.6 module debouncer ( input wire clk, reset, input wire sw, output reg db ); // symbolic state declaration localparam [2:0] zero = 3'b000, wait1_1 = 3'b001, wait1_2 = 3'b010, wait1_3 = 3'b011, ...
/** * 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 "../include/tune.v" // PentEvo project (c) NedoPC 2008-2009 // // Z80 memory manager: routes ROM/RAM accesses, makes wait-states for 14MHz or stall condition, etc. // // // fclk _/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\_/`\ // ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; vector<int> adj[105]; int n, k, dp[105][50], tmp[50]; void dfs(int u, int p) { dp[u][0] = dp[u][k + 1] = 1; for (int x = 0; x < adj[u].size(); x++) { int v = adj[u][x]; if (v == p) continue; dfs(v, u); memse...
/** * 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 p[200] = {0}; int main() { string a; int m; cin >> m; cin >> a; int n = a.length(); for (int i = 0; i < n; i++) { if (a[i] != ? ) p[a[i] - a ] = 1; if (a[i] != ? && a[i] - a >= m) { cout << IMPOSSIBLE << endl; ...
/** * 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 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(void) { int n; cin >> n; int ans = 1; for (int i = 1; i < n; i++) { ans *= 3; ans %= 1000003; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, sum; long long arr[105]; long long val[105]; void icchhipadey() { long long n; cin >> n; long long arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } long long f, x; cin >> f >> x; long long ans = 0; for (...
`include "assert.vh" module cpu_tb(); reg clk = 0; // // ROM // localparam MEM_ADDR = 4; localparam MEM_EXTRA = 4; reg [ MEM_ADDR :0] mem_addr; reg [ MEM_EXTRA-1:0] mem_extra; reg [ MEM_ADDR :0] rom_lower_bound = 0; reg [ MEM_ADDR :0] rom_upper_bound = ~0; wire [2...
/** * 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 t; cin >> t; while (t--) { int n; cin >> n; string s; cin >> s; vector<vector<int>> lcp(n, vector<int>(n)); for (int i = n - 1; i >= 0; --i) { for (int j = n - 1; j >= 0; --j) { lcp[i][j]...
// hub_mem /* ------------------------------------------------------------------------------- Copyright 2014 Parallax Inc. This file is part of the hardware description for the Propeller 1 Design. The Propeller 1 Design is free software: you can redistribute it and/or modify it under the terms of the GNU General Pub...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n; cin >> n; vector<pair<int, int>> d(n); for (auto &i : d) cin >> i.first, i.second = &i - &d[0] + 1; sort(d.begin(), d.end()); vector<pair<int, int>> e; vector<int> a; a.pus...
#include <bits/stdc++.h> using namespace std; void solve() { int N, M; string K; while (cin >> N >> M >> K) { K = K.substr(2); stringstream ss(K); int k; ss >> k; map<string, int> inp; for (int i = 0; i < (int)(N); i++) { string name; int level; ...
/******************************************************************************* * This file is owned and controlled by Xilinx and must be used solely * * for design, simulation, implementation and creation of design files * * limited to Xilinx devices or technologies. Use with non-Xilinx ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const int M = 1e5 + 10; const int INF = 2147483647; const int MOD = 1e9 + 7; int T, n, m; int sum; int a[N]; pair<int, int> b[N]; long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); } long long qpow(long...
#include <bits/stdc++.h> using namespace std; const int N = 200010; struct tree { int lt, rt; long long sumdis, sum, cnt; } a[N * 4]; int c[N], b[N], tmp[N], cnt, bb[N]; int find(int x) { int lt = 1, rt = cnt, mid; while (lt <= rt) { mid = (lt + rt) / 2; if (c[mid] == x) return m...
#include <bits/stdc++.h> using namespace std; const int N = 300005; const int mod = 1e9 + 7; const double eps = 1e-8; const double PI = acos(-1.0); long long qpow(long long a, long long b, long long p) { long long res = 1; while (b) { if (b & 1) res = res * a % p; a = a * a % p; b ...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: HORIE Tetsuya // // Create Date: 2015/11/27 19:43:29 // Design Name: // Module Name: Clocks // Project Name: TD4-GateLevel // Target Devices: Nexys4 DDR // Tool Versions: // Description:...
#include <bits/stdc++.h> int ATTENTION() { http: return 0; } using namespace std; const int iinf = 0x7fffffff; const long long linf = ~(1LL << 63); template <typename T> inline T gcd(T a, T b) { if (a < 0) return gcd(-a, b); if (b < 0) return gcd(a, -b); if (a < b) return gcd(b, a); ...