text
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; void solve(istream& in, ostream& out) { int n; in >> n; int res = n % 2 ? 0 : 1LL << (n / 2); out << res << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); std::istream& in(std::cin); std::ostream& out(std::cout); ...
//Legal Notice: (C)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 //simulation files), and any associated do...
#include <bits/stdc++.h> using namespace std; long long num_to_sig(long long x) { vector<int> v; while (x > 0) { v.push_back((x % 10) % 2); x /= 10; } int n = v.size(); long long ret = 0; for (int i = n - 1; i >= 0; i--) { ret *= 10; ret += v[i]; } return ret;...
#include <bits/stdc++.h> using namespace std; long long getint() { long long summ = 0, f = 1; char ch; for (ch = getchar(); !isdigit(ch) && ch != - ; ch = getchar()) ; if (ch == - ) { f = -1; ch = getchar(); } for (; isdigit(ch); ch = getchar()) summ = (summ << 3) +...
/*********************************************************/ // MODULE: Synchronous FIFO // // FILE NAME: sfifo_rtl.v // VERSION: 1.0 // DATE: January 1, 1999 // AUTHOR: Bob Zeidman, Zeidman Consulting // // CODE TYPE: Register Transfer Level // // DESCRIPTION: This module defines a Synchronous FIFO. The // FIFO me...
// (c) Copyright 1995-2015 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> using namespace std; char a[105][105], s[105], res[105], letter, letter2, help[105]; int i, j, k, N, lens, lena[105]; int main() { scanf( %d , &N); gets(a[103]); for (i = 0; i < N; i++) { gets(a[i]); lena[i] = strlen(a[i]); for (j = 0; j < lena[i]; j++) ...
#include <bits/stdc++.h> #pragma GCC optimize ( O3 ) #pragma GCC optimize ( Ofast ) using namespace std; #define int int64_t #define SQ(a) (a)*(a) const int INF = 1e15; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<vect...
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long n; cin >> n; vector<long long> apr(n + 1), arr(n); long long now = 1, next = 2; for (long long i = 0; i < n - 1; i++, next++) { long long a = 0, b = 0; cout <...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e3 + 7; const int mod = 998244353; int col[maxn]; namespace DSU { int far[maxn]; void init() { for (int i = 0; i < maxn; i++) far[i] = i; } int Find(int x) { return x == far[x] ? x : far[x] = Find(far[x]); } void Union(int x, int y)...
#include <bits/stdc++.h> using namespace std; constexpr long long INF = numeric_limits<long long>::max() / 4; constexpr long long n_max = 2e5 + 10; template <typename A, typename B> string to_string(pair<A, B> p); string to_string(const string &s) { return + s + ; } string to_string(const char c) {...
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0, sch = 0, nm = -100000, pnm = 10000; vector<int> v; scanf( %d , &n); for (int i = 0; i < n; i++) { int t; scanf( %d , &t); if ((t % 2 == 1) && (t > 0)) { pnm = ((pnm) < (t)) ? (pnm) : (t); ans...
/* Copyright (C) 2016 Cedric Orban 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 distributed in the ho...
#include <bits/stdc++.h> using namespace std; const long long mxn = 1e6 + 7; const long long mod = 1e9 + 7; const long long inf = 1e18 + 7; int dx[] = {+1, -1, 0, 0}; int dy[] = {0, 0, -1, +1}; pair<int, int> p[mxn]; map<long long, long long> f, s; int n; int a[mxn], ls[mxn]; long long ans; void...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, x, m, tmp, ans, sum, t; int a[N], b[N], h[N]; string s, p; map<string, int> pol; vector<int> nei[N]; bool mark[N]; void read_input() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] > 1 && ...
`timescale 1ps/1ps // // TV80 8-Bit Microprocessor Core // Based on the VHDL T80 core by Daniel Wallner () // // Copyright (c) 2004 Guy Hutchison () // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal i...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 9; long long n, a, b, val[MAX], incc[MAX], decc[MAX]; vector<int> g[MAX]; void dfs(int v, int p) { for (auto u : g[v]) if (u != p) dfs(u, v), decc[v] = max(decc[v], decc[u]), incc[v] = max(incc[v], incc[u]...
#include <bits/stdc++.h> using namespace std; int m, n, k; pair<long long, long long> ptsx[100005]; pair<long long, long long> ptsy[100005]; bool removed[100005]; long long get(int l, int r, int u, int d, int dep) { while (removed[ptsx[l].second]) l++; while (removed[ptsx[r].second]) r--; while ...
/** * 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 rca(a0,a1,a2,a3,a4,a5,a6,a7,b0,b1,b2,b3,b4,b5,b6,b7,car1,car2,car3,car4,car5,car6,car7,car8,s0,s1,s2,s3,s4,s5,s6,s7); input a0,a1,a2,a3,a4,a5,a6,a7,b0,b1,b2,b3,b4,b5,b6,b7; output car1,car2,car3,car4,car5,car6,car7,car8,s0,s1,s2,s3,s4,s5,s6,s7; assign s0=a0^b0^0; assign car1=(a0&b0)|(0&(a0^b0)); assign s1=a...
/** * 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) 2015 The Connectal Project // 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,...
// (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...
#include <bits/stdc++.h> using namespace std; char s[4005], t[4005], ax[4005]; int main() { scanf( %s%s , s, t); int n = strlen(s), m = strlen(t), ret = m; for (int i = n - 1; i >= 0; i--) s[i + m] = s[i], s[i] = 0; n += m; for (int i = 0; i < n; i++) { int ct = 0; for (int j = 0; ...
/* * Copyright (c) 2014, Aleksander Osman * 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 co...
#include <bits/stdc++.h> using namespace std; int a[400500], b[400500], n, tot; long long read() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 0 ; ch = getchar(); ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 5; int grid[maxn][maxn]; int main() { int n, ans = 0; scanf( %d , &n); for (int i = 0, x1, x2, y1, y2; i < n; i++) { scanf( %d%d%d%d , &x1, &y1, &x2, &y2); ans += (x2 - x1 + 1) * (y2 - y1 + 1); } printf( %d n , ...
#include <bits/stdc++.h> using namespace std; long long a[500005]; long long add[500005]; int main() { int i, j, n, x, y, z, m; long long sum; scanf( %d , &n); sum = 0; a[0] = 0; m = 1; for (i = 0; i < n; i++) { scanf( %d , &x); if (x == 1) { scanf( %d%d , &y, &z)...
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma comment(linker, /STACK:336777216 ) using namespace std; int IT_MAX = 1 << 17; const long long MOD = 1000000009; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const double PI = acos(-1); const double ERR = 1e-8...
/** * 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 main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long v1, v2, v3, vm; long long u1, u2, u3; cin >> v1 >> v2 >> v3 >> vm; for (u1 = v1; u1 <= 2 * v1; u1++) { for (u2 = v2; u2 <= 2 * v2; u2++) { for (u3 = 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> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; template <class S, class T> ostream &operator<<(ostream &os, const pair<S, T> v) { os << ( << v.first << , << v.second ...
#include <bits/stdc++.h> using namespace std; default_random_engine generator; uniform_int_distribution<int> distribution(1, INT_MAX); vector<vector<long long> > one(int sz) { vector<vector<long long> > ret; ret.resize(sz); for (int i = 0; i < ret.size(); i++) { ret[i].resize(sz); for (i...
/////////////////////////////////////////////////////////////////////////////// // Copyright (c) 1995/2009 Xilinx, Inc. // // 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 // //...
/** * 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...
////////////////////////////////////////////////////////////////////////////////// // Decoder for Cosmos OpenSSD // Copyright (c) 2015 Hanyang University ENC Lab. // Contributed by Kibin Park <> // Yong Ho Song <> // // This file is part of Cosmos OpenSSD. // // Cosmos OpenSSD is free software; you can r...
//----------------------------------------------------------------------------- // Pretend to be an ISO 14443 tag. We will do this by alternately short- // circuiting and open-circuiting the antenna coil, with the tri-state // pins. // // We communicate over the SSP, as a bitstream (i.e., might as well be // unframed,...
#include <bits/stdc++.h> using namespace std; signed main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int a[n]; for (long long int i = 0; i < n; i++) cin >> a[i]; long long int x = a[0]; for (long long int i = n - 1; i > 0; i--) {...
/* Copyright (c) 2020 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,...
/** * 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...
//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; const int maxN = (int)2E5 + 5; const long long mdls = (long long)1E9 + 7; vector<int> Adj[maxN]; vector<long long> suff[maxN], pref[maxN]; long long f[maxN], g[maxN], h[maxN]; int n; void DFS(int u) { f[u] = 1; for (int i = 0, sz = Adj[u].size(); 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...
/* * BCH Encode/Decoder Modules * * Copyright 2014 - Russ Dill <> * Distributed under 2-clause BSD license as contained in COPYING file. */ `timescale 1ns / 1ps `include "bch_defs.vh" /* * serial with inversion * Berlekamp–Massey algorithm * * sigma_i^(r) = sigma_i^(r-1) + d_rp * beta_i^(r) (i = 1 to t-1) *...
// 3rd party code: from Swapforth [1] // // Copyright (c) 2015 James Bowman // // [1] https://github.com/jamesbowman/swapforth // /* Copyright (c) 2015, James Bowman All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditi...
#include <bits/stdc++.h> using namespace std; int main() { long long l, r; cin >> l >> r; long long x = r, y = 0; while (x > 0) { ++y; x /= 10; } x = 5; long long k = y; for (int i = 0; i < k - 1; ++i) { x *= 10; } if (r < x) x = r; else if (l > x)...
#include <bits/stdc++.h> using namespace std; string inp[100005]; int num[100005]; int tl; int ch[1200005][27]; int fail[1200005], len[1200005], elen[1200005]; long long cost[1200005]; int rt = 1, tot = 1, last = 1; void add(int x, int c, int _elen) { int p = last; int np = ++tot; len[np] ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10, maxm = 2e6 + 10; const long long INF = 0x3f3f3f3f, mod = 1e9 + 7; int casn, n, m, k; namespace graph { vector<int> g[maxn]; int all, sz[maxn], root, maxt; bool vis[maxn]; int dfs_root(int now, int fa) { int cnt = 1; for (...
#include <bits/stdc++.h> using namespace std; int byk[3][3]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string s; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == B ) byk[i % 3][0]++; if (s[i] == G ) byk[i % 3][1]...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.4 (win64) Build Wed Dec 14 22:35:39 MST 2016 // Date : Mon Feb 27 15:47:58 2017 // Host : GILAMONSTER running 64-bit major release (...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int cnt = 0; while (n > 0) { if (n >= 100) { n -= 100; cnt++; } else if (n >= 20) { n -= 20; cnt++; } else if (n >= 10) { n -= 10; cnt++; } else if (n >...
#include <bits/stdc++.h> using std::map; const int MAXN = 1000 + 3; int table[MAXN][MAXN]; int n, m, k; map<int, int> r, c; int main(int argc, char *argv[]) { scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= n; ++i) { r[i] = i; for (int j = 1; j <= m; ++j) { if (i == 1) c[j] = j...
#include <bits/stdc++.h> using namespace std; long long int a[1000001]; long long int b[1000001]; bool marked[1000001]; int main() { long long int n, i, j, k, x, y, fin_ans = 0, sum = 0; cin >> n >> k; a[0] = 0; for (i = 1; i <= n; i++) { cin >> a[i]; sum += a[i]; fin_ans += ...
#include <bits/stdc++.h> using namespace std; int N, K; int gru0[] = {0, 1, 2}; int gru1[] = {0, 1, 0, 1, 2}; int grundy(int x) { if (K) { if (x < 5) { return gru1[x]; } else if (x & 1) { return 0; } else { return grundy(x / 2) == 1 ? 2 : 1; } } else { ...
#include <bits/stdc++.h> using namespace std; long long res, d, e, k; int N; int h[2020]; long long dp[2020][2020]; long long pw(long long a, long long n) { long long ret = 1; while (n) { if (n % 2) ret *= a, ret %= 998244353; a *= a, a %= 998244353; n >>= 1; } return ret; ...
#include <bits/stdc++.h> using namespace std; const int INF = 123456789; template <class T> void scanint(T& x) { register int c = getchar(); x = 0; int m = 0; if (c == - ) { m = 1; } for (; (c < 48 || c > 57); c = getchar()) ; for (; c > 47 && c < 58; c = getchar()) { ...
/* * 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...
// DESCRIPTION: Verilator: Verilog Test module for Issue#1609 // // This file ONLY is placed into the Public Domain, for any use, // without warranty, 2020 by Julien Margetts. module t (/*AUTOARG*/ out, out2, in ); input [9:0] in; output reg [3:0] out; output reg [3:0] out2; // Should be no latch h...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 10; struct Node { int a, b, d; } p[MAXN]; int n, k; bool cmp(Node aa, Node bb) { return aa.d < bb.d; } bool cmp2(Node aa, Node bb) { return aa.d > bb.d; } int main() { scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) sca...
#include <bits/stdc++.h> using namespace std; void solve() { int n, m, k, fri = 0; cin >> n >> m >> k; vector<int> v; for (int i = 0; i < m + 1; i++) { int t; cin >> t; v.push_back(t); } int la = v[m]; vector<int> labit; for (int i = 0; i < 32; i++) { if ((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; int n; string c[int(20)]; int r[int(20)], b[int(20)]; int count(int mask, char color) { int ans = 0; for (int s = 0, __R = n - 1; s <= __R; s++) if (!((mask >> s) & 1) && c[s][0] == color) ans++; return ans; } int f(int i, int j, int k) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 2, maxm = 1e7 + 5; struct node { int bg, ed, id; } a[maxn]; int n, ans[maxn]; bool vis[maxm]; bool cmp(node a, node b) { return a.ed < b.ed; } int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d %d ,...
// megafunction wizard: %FIFO%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: scfifo // ============================================================ // File Name: fifo.v // Megafunction Name(s): // scfifo // // 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; double alto, ancho, altomesa, anchomesa, ancho1, alto1, x_1, x_2, y_1, y_2; double abajo() { if (altomesa <= y_1) return 0; return altomesa - y_1; } double arriba() { if (altomesa <= alto - y_2) return 0; return altomesa - (alto - y_2); } doubl...
//////////////////////////////////////////////////////////////////////////////// // // Filename: helloworld.v // {{{ // Project: wbuart32, a full featured UART with simulator // // Purpose: To create a *very* simple UART test program, which can be used // as the top level design file of any FPGA program. // // With s...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; int i, count = 0; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 1; i < n - 1; i++) { if (a[i] == 0 && a[i - 1] == 1 && a[i + 1] == 1) { count++; i += 2; } } ...
#include <bits/stdc++.h> using namespace std; int M, K, i, st, ed, ans[2], arr[100005]; int main() { cin >> M >> K; for (i = st = ed = 0; i < M; i++) cin >> arr[i]; sort(arr, arr + M, greater<int>()); while (1) { while ((ed + 1) < M && (arr[st] - arr[ed + 1]) <= K) K -= (arr[st] - ar...
/* * Milkymist VJ SoC fjmem flasher * Copyright (C) 2010 Michael Walle <> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program is distributed in t...
#include <bits/stdc++.h> using namespace std; int vis[10100]; int dist[10100]; int pre[10100], cntt[30]; char str[10100]; struct Edge { int u, v, c, cost, next; } edge[1000100]; int anss, head[10100], cnt; void init() { cnt = 0; memset(head, -1, sizeof(head)); } void addedge(int u, int...
#include <bits/stdc++.h> using namespace std; const long long linf = 1e18 + 5; const int mod = (int)1e9 + 7; const int logN = 17; const int inf = 1e9; const int N = 2e5 + 5; int main() { int n, t; vector<pair<int, int> > ans; scanf( %d , &n); queue<int> q; for (int i = 1; i <= n; 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; long long int power(long long int x, long long int n) { if (n == 0) return 1; else if (n % 2 == 0) return power(x * x, n / 2); else return x * power(x * x, (n - 1) / 2); } long long int highestPowerof2(long long int n) { long long i...
#include <bits/stdc++.h> using namespace std; vector<int> adj[300003]; vector<int> adje[300003]; int d[300003]; int pickd[300003]; bool vis[300003]; int n, m; int x; int dfs1(int u) { int ans = 0; if (d[u] == -1) x = u; else if (d[u] == 1) ++ans; vis[u] = true; for (int...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, t, t1 = 0; cin >> n >> k; cin >> t1; for (int i = 2; i <= n; i++) { cin >> t; t1 += t + 1; } if (t1 == k) cout << YES ; else cout << NO ; }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10, INF = 1e9; vector<int> g[N], r[N], out; int cnt[N], ans = INF, sum = 0; int dfs(int v, int par) { for (int i = 0; i < g[v].size(); i++) if (g[v][i] != par) cnt[v] += dfs(g[v][i], v); for (int i = 0; i < r[v].size(); 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; int main() { string a, b; cin >> a >> b; int x = 0, y = 0; int n = b.length(); while (x < n && a[x] == b[x]) x++; while (y < n && a[n - y] == b[n - 1 - y]) y++; int res = x + y + 2 - (n + 1); res = max(0, min(res, n + 1)); cout << res...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:45:30 01/30/2016 // Design Name: // Module Name: third_step // Project Name: // Target Devices: // Tool versions: // Description: // // Depe...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed under the Creative Commons Public Domain, for // any use, without warranty, 2009 by Wilson Snyder. // SPDX-License-Identifier: CC0-1.0 module t (/*AUTOARG*/); // IEEE: integer_atom_type byte d_byte; shortint d_shortint;...
`timescale 1ns / 1ps //Control Unit. module CUnit( input wire clk, input wire reset, output reg rw, output reg [31:0] wD, input wire [31:0] rD, output reg e, output reg [9:0] MAR, input wire le, input wire eq, input wire gt, input wire [31:0] c, output reg [31:0] a, output reg [31:0] b, output reg [3:0] s...
#include <bits/stdc++.h> using namespace std; const int Maxlen = 2e5 + 2; long long ans; long long lt[Maxlen], ls[2 * Maxlen]; int n, m, dpt[Maxlen], dps[Maxlen]; char ct[Maxlen], cs[2 * Maxlen]; long long cmp(int pos) { if (cs[0] != ct[pos] || ls[0] > lt[pos]) return 0; if (m == 1) return lt[pos]...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; string s; while (n--) cin >> s; bool wall = false; int segments = 0, i = 0; while (i < s.size()) { if (!wall && s[i] == B ) { segments++; wall = true; } else if (wall && s[i] ...
#include <bits/stdc++.h> using namespace std; int main() { int a, k1 = 0, k2 = 0; cin >> a; string h; cin >> h; string *s = new string[a]; for (int i = 0; i < a; i++) { cin >> s[i]; if (s[i].substr(s[i].size() - 3, 3) == h) k1++; else k2++; } if (k1 ...
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; const int maxn = 1001000; const int mod = 1000000007; int a[maxn], f[maxn], r[maxn]; int main() { int n; scanf( %d , &n); for (int e = 1; e <= n; e++) scanf( %d , a + e); auto mul = [](int x...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1; const long long MOD = 1; long long _gcd(long long a, long long b) { if (b == 0) return a; return _gcd(b, a % b); } long long gcd(long long a, long long b) { a = abs(a), b = abs(b); if (a < b) swap(a, b); return _gcd(a, b);...
module stimulus (output reg A, B); initial begin // both inputs are x #0 {A, B} = 2'bxx; // both inputs are z #10 {A, B} = 2'bzz; // one input is a zero #10 {A, B} = 2'b0x; #10 {A, B} = 2'bx0; #10 {A, B} = 2'b0z; #10 {A, B} = 2'bz0; // one input is a one #10 {A, B} = 2'b...
#include <bits/stdc++.h> using namespace std; struct yts { long long dp[210][210]; } a, ans, t; int ch[210][26], fail[210], q[210], root = 1; long long w[210], b[210]; int n, m, tot = 1; char s[210]; long long L; void insert(int id) { int x = root, len = strlen(s + 1); for (int i = 1; i <=...
#include <bits/stdc++.h> using namespace std; int nos; void split(int n) { if (nos == 0 || n == 1) cout << n << ; else { --nos; split(n / 2); split(n / 2); } } int main() { ios::sync_with_stdio(false); int n, k; cin >> k >> n; if (n > k) cout << NO...
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; struct node { int c, f, l, i; } a[maxn], b[maxn]; bool cmp1(node a, node b) { return a.f < b.f; } bool cmp2(node a, node b) { return a.c > b.c; } int main() { int n, d, s; scanf( %d%d%d , &n, &d, &s); int nn = n; in...
// system_acl_iface_acl_kernel_interface_mm_interconnect_0_avalon_st_adapter.v // This file was auto-generated from altera_avalon_st_adapter_hw.tcl. If you edit it your changes // will probably be lost. // // Generated using ACDS version 15.1 185 `timescale 1 ps / 1 ps module system_acl_iface_acl_kernel_interface_m...
/* * Copyright (c) 2015, Arch Labolatory * 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 lis...
// File : ../RTL/serialInterfaceEngine/usbTxWireArbiter.v // Generated : 11/10/06 05:37:24 // From : ../RTL/serialInterfaceEngine/usbTxWireArbiter.asf // By : FSM2VHDL ver. 5.0.0.9 ////////////////////////////////////////////////////////////////////// //// ...
#include <bits/stdc++.h> using namespace std; const int M = 450007; int read() { int ans = 0, f = 1, c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { ans = ans * 10 + (c - 0 ); c = getchar(); } return...
#include <bits/stdc++.h> using namespace std; const long long LLINF = 9223372036854775807LL; const int INF = 2147483647; const int MOD = 1000000007; const double eps = 1e-7; const double PI = acos(-1.0); int dr[] = {1, 0, -1, 0, -1, 1, 1, -1}; int dc[] = {0, -1, 0, 1, 1, 1, -1, -1}; int m; pair<int,...
#include <bits/stdc++.h> using namespace std; long long t[505]; long long p[505][505]; long long dp[505][505]; const long long oo = 4557430888798830399LL; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int n, m, k; cin >> n >> m >> k; vector<string> s(n); for (auto &i : s) cin >>...
#include <bits/stdc++.h> using namespace std; const long long M = 1e9 + 7; const long long mod = 998244353; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, m, k; vector<int> a; int f(int off) { int q = 0; int left = m - 1; int at_w = k; for (int i = off; i < ...