text
stringlengths
59
71.4k
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2005 by Wilson Snyder. module t (/*AUTOARG*/ // Inputs clk ); input clk; // Some inputs we'll set to random values reg [6:0] addr; reg [6:0] e0; reg [5:0] e1...
/** * @module ID_EX * @author sabertazimi * @email * @brief ID_EX pipeline register * @input clk clock signal * @input rst reset signal * @input en load enable signal * @input ID_PC PC value in ID stage * @input ID_IR instruction value in ID stage * @input ID_writetolo writetolo signal in ID stage * @input ...
// NeoGeo logic definition (simulation only) // Copyright (C) 2018 Sean Gonsalves // // 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) an...
#include <bits/stdc++.h> using namespace std; int uf[310100]; int get_fa(int x) { return uf[x] == x ? x : uf[x] = get_fa(uf[x]); } struct Edge { Edge *next; int np; int id; } E[310100 * 2], *V[310100]; int tope = -1; void add_edge(int x, int y, int id) { E[++tope].np = y; E[tope].id = ...
`include "LookupTable.v" module GeneralControl ( input [5:0] op_i, input [5:0] func_i, input is_equal_i, output reg [1:0] PC_ctrl_o, output reg [4:0] EX_ctrl_o, output reg [1:0] MEM_ctrl_o, output reg [1:0] WB_ctrl_o ); /** * PC_ctrl_o <= { PC_mux(2) } * PC_mux[0] -> jump/branch, PC_mux[1] ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 5; vector<long long> f; vector<long long> s; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long a, b; cin >> a >> b; while (a > 0) { long long rem = a % 10; a /= 10; f.p...
`timescale 1ns / 1ps /* Group Members: Nikita Eisenhauer and Warren Seto Lab Name: Adder Design Design Description: Verilog Module to implement a 64-bit ripple adder */ module ripple_adder_64 ( input [63:0] A, input [63:0] B, output [63:0] SUM, output CARRY ); // Create wires to connect each fu...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; const int M = 2e3 + 5; const int INF = 0x7fffffff; const int mod = 998244353; const double eps = 1e-8; const double pi = acos(-1); int n, m; char str[N]; int f[N][26]; template <class T> inline void read(T &x) { char c; ...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; cout << (n % 4 == 0 ? YES : NO ) << n ; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { solve(); } return 0; }
/******************************************************************************* * 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; struct E { int to, col, time, ind; E(int to, int col, int time, int ind) : to(to), col(col), time(time), ind(ind) {} }; int n, m, cnt; vector<E> g[50000]; int a[50000], b[50000], c[50000], d[50000], t[50000]; map<int, pair<int, int> > colInd; ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, p, a; cin >> n >> k >> p; if (n % 2 && k) { n--; k--; } if (2 * k > n) { long long t = 2 * k - n; n -= t; k -= t; } while (p--) { cin >> a; if ((a > n) || ((a % 2 == 0) &&...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double EPS = 1e-9; const int N = (1 << 15); const int OO = 200000; struct edge { int from, to, w; edge(int from, int to, int w) : from(from), to(to), w(w) {} bool operator<(const edge& e) const { return w < e.w; } ...
/** * 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 N = 100000 + 10; map<long long, long long> mp; int main() { long long n, k, p, x, ans = 0; scanf( %lld%lld%lld , &n, &p, &k); for (long long i = 0; i < n; ++i) { scanf( %lld , &x); mp[((x * x % p * x % p * x % p - x * k % p) % p + 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...
#include <bits/stdc++.h> using namespace std; int mod = 1000000007; long long int gcd(long long int a, long long int b) { return b ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a * b / gcd(a, b); } long long int bpow(long long int a, long long int b) { long long int res = 1; while (b > 0...
#include <bits/stdc++.h> using namespace std; bool cmp(const pair<long long int, long long int> &a, const pair<long long int, long long int> &b) { return a.second < b.second; } int main() { long long int n, k, ai, bi, total = 0, ans = 0; vector<long long int> a; vector<pair<long long ...
#include <bits/stdc++.h> using namespace std; const long long int maxn = 2e5 + 1; void solve() { string s, even, odd; cin >> s; for (long long int i = 0; i < s.length(); i++) { long long int val = s[i] - 0 ; if (val % 2 == 0) even += s[i]; else odd += s[i]; } ...
#include <bits/stdc++.h> using namespace std; struct node { int va, num; bool operator<(const node &o) const { return va < o.va; } } a[100005]; int n, m, nub, lastnode, nextnode, now; int mark[400005], mm; int ans[400005], co; vector<int> save[400005]; void dfs(int h) { mark[h] = 1; for ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; if (n / k % 2 == 0) { cout << NO ; } else { cout << YES ; } return 0; }
#include <bits/stdc++.h> using namespace std; struct node { long long w, id; bool friend operator<(node a, node b) { if (a.w == b.w) return a.id < b.id; else return a.w < b.w; } } a[1000004]; long long b[1000004][4]; long long l[1000004]; long long r[1000004]; int m...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long mod = 1e9 + 7; const int maxn = 1e5 + 5; long long a[15], b[15]; int main() { for (int i = 0; i < 14; ++i) { cin >> a[i]; } long long ans = 0; for (int i = 0; i < 14; ++i) { if (a[i] == 0) c...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n, m, len[maxn << 2]; bool first[maxn << 2]; long long mm[maxn], rr[maxn], ss[maxn], last[maxn << 2]; vector<long long> summ[maxn << 2], sumr[maxn << 2]; vector<int> tree[maxn << 2]; bool cmp(int a, int b) { return mm[a] * rr[b] ...
/* * Copyright (c) 2000 Stephen Williams () * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU * General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * ...
#include <bits/stdc++.h> using namespace std; vector<vector<int> > adj(2001); int match[2001 + 1], dis[2001 + 1]; bool visited[2001 + 1], minimumVertexCover[2001], maximumIndependentSet[2001]; const int inf = 1E9; void ResetVisited() { for (int i = 0; i <= 2001; ++i) { visited[i] = 0; } } ...
module timer(ssd_out,clk,reset); input clk,reset; output [6:0] ssd_out; reg [25:0] ticker; reg [3:0] counter; wire [3:0] ssd_in; assign ssd_in = counter; seven_seg_decoder ssd(ssd_out,ssd_in); initial begin ticker = 49999999; counter = 15; end always @(posedge clk or negedge reset) begin ...
/* * yosys -- Yosys Open SYnthesis Suite * * Copyright (C) 2012 Clifford Wolf <> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * T...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: MossbauerLab // Engineer: EvilLord666 (Ushakov MV) // // Create Date: 01:41:52 01/09/2019 // Design Name: // Module Name: messbauer_saw_tooth_generator // Project Name: messbauer_...
#include <bits/stdc++.h> using namespace std; template <class t> inline void read(t& res) { char ch; while (ch = getchar(), !isdigit(ch)) ; res = ch ^ 48; while (ch = getchar(), isdigit(ch)) res = res * 10 + (ch ^ 48); } template <class t> inline void print(t x) { if (x > 9) print(...
#include <bits/stdc++.h> using namespace std; map<string, int> mp; int n, m, cc; char s[1010]; int a[1010], cnt[1010]; void getcc(string s) { if (mp.find(s) == mp.end()) mp[s] = cc++; cnt[mp[s]]++; } int main() { int i, j, k; while (scanf( %d%d , &n, &m) > 0) { for (i = 0; i < n; i...
#include <bits/stdc++.h> using namespace std; vector<long long> com; vector<long long> all; long long c, a, n, k, mm; void solve() { long long s = 0, e = (long long)1e9 * 2 + 5; long long mid = 0; long long sum = 0; while (s <= e) { mid = (s + e) / 2; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, m; cin >> n >> m; vector<string> v, vec; for (long long i = 1; i <= n; i++) { string s; cin >> s; v.push_back(s); } for (long ...
#include <bits/stdc++.h> using namespace std; const int ma = 35; int n, m, mat[ma][ma]; int main() { int t; scanf( %d , &t); int ans, one, zero; int sum, temp; int l, r; while (t--) { scanf( %d%d , &n, &m); one = zero = 0; for (int i = 1; i <= n; i++) for (int j...
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; long long powmod(long long a, long long b) { long long res = 1; for (; b; b >>= 1) { if (b & 1) (res *= a) %= mod; (a *= a) %= mod; } return res; } int main() { ios::sync_with_stdio(false); cin.tie(0);...
#include <bits/stdc++.h> const int N = 3005; int n, D, h[N], nxt[N], adj[N], fa[N], t, f[N][N], inv[N], ifac[N], C[N][N], g[N], s[N][N]; inline void dfs(const int x) { for (register int i = 1; i <= n; ++i) f[x][i] = 1; for (register int i = h[x], j, v; i; i = nxt[i]) for (dfs(v = adj[i]), j = ...
#include <bits/stdc++.h> using namespace std; struct ip { long long a, b, c, d, m; }; ip getip(long long num, int mm) { return {(num & (255 << 24)) >> 24, (num & (255 << 16)) >> 16, (num & (255 << 8)) >> 8, num & 255, mm}; } vector<ip> numtoip(pair<long long, long long> p) { long lon...
#include <bits/stdc++.h> using namespace std; const int MAXN = 200100; int N, M; vector<int> edge[MAXN]; int dep[MAXN]; int croute[MAXN]; int par[MAXN]; pair<int, int> cover[MAXN]; bool seen[MAXN]; void run(int cloc, int last, int cdep) { seen[cloc] = true; croute[cdep] = cloc; dep[cloc]...
// implementation of a toggle element // See Micropipelines, I. E. Sutherland Sutherland, Sproull, and Associates, Palo Alto, CA // Published in: // Communications of the ACM // Volume 32 Issue 6, June 1989 // Pages 720-738 // ACM New York, NY, USA // For the implementation, see : // The Design an...
#include <bits/stdc++.h> int n, k, ans; long long s[200005], a[200005], b[200005]; void neg() { for (int i = 0; i <= n; i++) { a[i] = -a[i]; b[i] = -b[i]; } } void trans() { b[n]--; b[0] += 2; for (int i = 1; i < n; i++) b[i]++; for (int i = 0; i < n; i++) { b[i + 1] ...
#include <bits/stdc++.h> using namespace std; #define mod1 1000000007 #define mod2 998244353 #define ff first #define ss second #define int long long #define ll unsigned long long #define pb push_back #define mp make_pair #define pii pair<int,int> #define inf 9e18 #define N 150...
// (c) Copyright 1995-2016 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 ...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; const int N = 500005; const int MOD = 1e9 + 7; int i, n, m, k, rs, x, y; long long val[N]; map<int, int> p; map<long long, vector<pair<int, int>>> M...
//---------------------------------------------------------------------------- // Copyright (C) 2001 Authors // // 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 ...
#include <bits/stdc++.h> using namespace std; const int64_t INF = (1 << 30) - 1; const long long oo = (1ll << 62) - 1; const long double PI = 3.1415926535898; const int64_t N = 100000 + 5; int64_t n; vector<int64_t> a[N]; int64_t d[5][N]; int64_t mau[N]; int64_t c[5][5]; int64_t dfs(int64_t u, int...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2009 Xilinx, Inc. // All Right Reserved. /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor : Xilinx // \ \ \/ Version : 11....
// Copyright 1986-1999, 2001-2013 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2013.4 (lin64) Build 353583 Mon Dec 9 17:26:26 MST 2013 // Date : Mon Mar 31 20:12:08 2014 // Host : macbook running 64-bit Arc...
/* ------------------------------------------------------------------------------- This file is part of the hardware description for the Propeller 1 Design for Pipistrello LX45. The Propeller 1 Design is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License a...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const long long INFLL = 1e18 + 1; const int MAX = 200001; const long long MOD = 1000000007; long long inq(long long k, long long q) { if (q == 0) return 1; long long l = inq(k, q / 2); if (q % 2 == 0) return l * l % MOD; ...
/* * 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[2000]; int n; inline bool check() { int c = 0; for (int i = 0; i < n; ++i) if (a[i] + 1 == a[i + 1]) ++c; if (c == n) return true; else return false; } inline void push() { for (int i = 0; i <= n; ++i) { if (i % ...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const double eps = 1e-6; const long long INF = 0x3f3f3f3f3f3f3f3fll; const int inf = 0x3f3f3f3f; const int mod = 998244353; const int maxn = 1e6 + 100; long long qpow(long long a, long long b) { long long ret = 1; a %= mod...
module LUT1(output F, input I0); parameter [1:0] INIT = 0; assign F = I0 ? INIT[1] : INIT[0]; endmodule module LUT2(output F, input I0, I1); parameter [3:0] INIT = 0; wire [ 1: 0] s1 = I1 ? INIT[ 3: 2] : INIT[ 1: 0]; assign F = I0 ? s1[1] : s1[0]; endmodule module LUT3(output F, input I0, I1, I2); parameter [7:...
#include <bits/stdc++.h> using namespace std; using LL = long long; constexpr int N = 1e5 + 5; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k, m; cin >> n >> k >> m; vector<int> in(k); for (int &e : in) cin >> e; sort(begin(in), end(in)); const int A = accum...
#include <bits/stdc++.h> using namespace std; const long long N = 200005; const long long M = 1000000007; long long n, d; string s, t1, t2, t; long long rt = 1, tot = 1, ch[15][N], ed[N], fail[N]; void insert(string x) { long long len = x.length(), now = rt; for (long long i = 0; i < len; i++) { ...
#include <bits/stdc++.h> using namespace std; mt19937 dadi(chrono::high_resolution_clock::now().time_since_epoch().count()); const int N = 100 + 5, K = 1e3 + 5; int n, m, k, w[N], p[K], cnt[N][K]; struct game { int u, v, t; } a[K]; inline int add(int u, int v) { shuffle(p, p + k, dadi); int mx...
#include <bits/stdc++.h> using namespace std; const int N = 100020, mo = 1e9 + 7; int n, second[N], x, y, cnt, dfn[N], vis[N]; int dot[N], size; int l[N], r[N]; long long ans = 1; set<pair<int, int> > L[N], R[N]; struct Dot { int x, y; } s[N]; inline void read(int &x) { x = 0; char c = g...
//+FHDR------------------------------------------------------------------------ //Copyright (c) 2013 Latin Group American Integhrated Circuit, Inc. All rights reserved //GLADIC Open Source RTL //----------------------------------------------------------------------------- //FILE NAME : //DEPARTMENT : IC Design / Veri...
/** * 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; char s[500001], t[500001]; long long nt[10000001], n, k, m; long long c[2]; void kmp(long long x, char a[]) { int i, j; for (nt[0] = j = -1, i = 1; i < x; nt[i++] = j) { while (~j && a[j + 1] != a[i]) j = nt[j]; if (a[j + 1] == a[i]) j++; }...
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y) { if (y == 0) return 1; if (y & 1) return (x * power(x, y - 1)) % 1000000007; long long int t = power(x, y / 2); return (t * t) % 1000000007; } int main() { ios_base::sync_with_stdio(false); ...
/** * 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 ax, ay, bx, by, cx, cy; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> ax >> ay >> bx >> by >> cx >> cy; if ((by - ay) * (cx - bx) == (cy - by) * (bx - ax)) cout << NO n ; else if ((by - ay) * (by - ay) + (bx - ax) * (bx ...
#include <bits/stdc++.h> using namespace std; void solve() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if (x1 == x2 && y1 == y2) { cout << 10 ; return; } if (x1 == x2) { cout << 2 * (abs(y2 - y1) + 1) + 4; return; } if (y1 == y2) { cout << 2 * (abs(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 n, m, dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0}, mp[100005], b; int cheak(int x, int y) { if (abs(x - y) == m || abs(x - y) == 1) return 1; else return 0; } void dfs(int x) { if (x == n * m) { b = 1; cout << YES << endl; ...
#include <bits/stdc++.h> const double eps = 1e-9; const double pi = acos(-1); using namespace std; struct sx {}; bool cmp(int a, int b) { return a > b; } long long t1, t2, t3; int main() { int n, m; cin >> n >> m; int x = (n + m) / 3; while (t1 < x && ((n >= 1 && m >= 2) || (n >= 2 && m >=...
#include <bits/stdc++.h> using namespace std; int mx = INT_MIN, n, a[10]; char x; int main() { cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= 7; j++) { cin >> x; a[j] += x - 48; } } for (int i = 1; i <= 7; i++) if (mx < a[i]) mx = a[i]; cout <...
/******************************************************************************* * 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; int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); } void solve(int test) { int n, k; cin >> n >> k; vector<pair<pair<int, int>, int>> v(n); int i, j, l; for (i = (0); i < (n); ++i) cin >> v[i].first.first >> v[i].first.second; for (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...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int M = 205; long long n, m, k, cnt, ans; long long g[N], h[N], dp[N][M]; struct redpocket { long long s, t, d, w; bool operator<(const redpocket &x) const { if (w == x.w) return d < x.d; return w < x.w; } ...
/////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2014 Francis Bruno, 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 Found...
#include <bits/stdc++.h> using namespace std; const int N = 1005; int n, k, dep[N], fa[N]; bitset<N> s[2], t[4], a, b; vector<bitset<N> > S; inline bitset<N> qry(bitset<N> x, int y) { y = min(y, n - 1); char c[N]; putchar( ? ); for (int i = 1; i <= n; i++) printf( %d , x[i] ? y : 0); pu...
#include <bits/stdc++.h> using namespace std; string s1, s2, virus; pair<int, int> dp[105][105][105]; int l1, l2, lvirus; string ans = ; int pi[105]; void pf(string s) { memset(pi, 0, sizeof(pi)); int n = (int)s.length(); for (int i = 1; i < n; ++i) { int j = pi[i - 1]; while (j ...
/* * 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; while (scanf( %d , &n) != EOF) { if (n & 1) { int d = (n - 1) / 2; printf( %d n , d * 2 + d * d - d); for (int i = 2; i < n; i += 2) { for (int j = 2; j < i; j += 2) { printf( 4 %d %d %d %d ...
#include <bits/stdc++.h> using namespace std; struct no { long long i, h, m; }; long long dp[40][40][40]; char str[40]; no pre[40][40][40]; long long pw[19]; vector<char> ans; int main() { long long n; scanf( %lld , &n); scanf( %s , str + 1); pw[0] = 1; for (long long i = 1; i ...
// 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...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const double EPS = 1e-9; const long long INF = 1e18 + 2007; const double PI = 3.1415926535897932384626433832795; const long long N = 200005; long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; } signed main(...
/** * 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 spiral_16( i_data, o_data_4, o_data_13, o_data_22, o_data_31, o_data_38, o_data_46, o_data_54, o_data_61, o_data_67, o_data_73, o_data_78, o_data_82, o_data_85, o_data_88, ...
#include <bits/stdc++.h> const int N = 1000001; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m, k; string s; cin >> n >> k >> s; m = s.size(); int last[200]; memset(last, -1, sizeof last); for (int i = 0; i < m; i...
#include <bits/stdc++.h> using namespace std; int n, ret, f[26]; vector<pair<pair<int, int>, int> > ss; int call(char c) { return int(c) - int( a ); } int main() { cin >> n; string s; for (int i = 1; i <= n; i++) { cin >> s; ss.push_back(make_pair(make_pair(call(s[0]), call(s[long(s.le...
/* All files are owned by Kris Kalavantavanich. * Feel free to use/modify/distribute in the condition that this copyright header is kept unmodified. * Github: https://github.com/kkalavantavanich/SD2017 */ `timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Creat...
#include <bits/stdc++.h> using namespace std; int main() { string x, y, z; int a = 0, c = 0; cin >> x; cin >> y; cin >> z; for (int i = 0; i < x.length(); i++) { for (int j = 0; j < z.length(); j++) { if (x[i] == z[j]) { c += 1; z[j] = 1 ; break; ...
module top; parameter neg_pose = -2**2; parameter neg_poso = -2**3; parameter m1_pose = -1**2; parameter m1_poso = -1**3; parameter zero_pos = 0**2; parameter one_pos = 1**2; parameter pos_pos = 2**2; parameter neg_zero = -2**0; parameter m1_zero = -1**0; parameter zero_zero = 0**0; parameter one...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2015 Xilinx, Inc. // All Rights Reserved /////////////////////////////////////////////////////////////////////////////// // ____ ____ // / /\/ / // /___/ \ / Vendor: Xilinx // \ \ \/ Version: 1.0 // \ ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; size_t pos1 = s.find( AB ), pos2 = s.find( BA ); string tmp = s; s.erase(0, pos1 + 2); tmp.erase(0, pos2 + 2); bool check = false; if (pos1 == string:...
#include <bits/stdc++.h> using namespace std; long long n, m; inline long long read() { long long 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 - 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...
//############################################################################# //# Function: Falling Edge Sampled Register # //############################################################################# //# Author: Andreas Olofsson # ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k, i; cin >> n >> m >> k; vector<long long int> a(n), s1(m, 0), e1(m, 0), tot1(m, 0), s2(n, 0), e2(n, 0), tot2(n, 0); long long int b[m][3]; long long int c[k][2]; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); cout.tie(NULL); ios_base::sync_with_stdio(false); int t; cin >> t; while (t--) { string s; cin >> s; int ans = 0; int one; bool turn = true; while (s.size() != 0) { one = ...
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { int n; cin >> n; vector<int> v(n); set<int> st; for (int i = 0; i < n; i++) { cin >> v[i]; st.insert(v[i]); } sort(v.begin(), v.end()); int mx = v.bac...
/** * 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; static long long mi[400005][20]; static bool mark[400005][20]; static long long psum[400005]; long long f(int x, int k) { if (k == 0) return psum[x]; if (mark[x][k]) return mi[x][k]; mark[x][k] = 1; return mi[x][k] = min(f(x, k - 1), f(x + (1 << (k...
/* * 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 int MOD = 1e9 + 7; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; long long int a[n]; for (long long int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout <<...