text
stringlengths
59
71.4k
//----------------------------------------------------------------------------- // system_tb.v //----------------------------------------------------------------------------- `timescale 1 ps / 100 fs `uselib lib=unisims_ver // START USER CODE (Do not remove this line) // User: Put your directives here. Code in this...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; char ar[n]; for (int i = 0; i < n; ++i) { cin >> ar[i]; } int co = 0; vector<int> po; for (int i = 0; i < n - 1; ++i) { if (ar[i] == 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...
`ifdef __ICARUS__ `define SUPPORT_CONST_OUT_OF_RANGE_IN_IVTEST `endif module top; reg pass; reg [5:0] cond; reg [2:1] expr; integer result; always @(cond or expr) begin casex (cond) 6'b01_??10 : result = 1; {2'b10, 4'b??10} : result = 2; `ifdef SUPPORT_CONST_OUT_OF_RANGE_IN_IVT...
#include <bits/stdc++.h> using namespace std; template <typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>; template <typename T> using max_pq = priority_queue<T>; const int inf = 2e9 + 5; const long long l_inf = 2e18 + 5; const int mod_v = 1e9 + 7; const int max_n = 1e5 + 5; const ...
////////////////////////////////////////////////////////////////////////////////// // // This file is part of the N64 RGB/YPbPr DAC project. // // Copyright (C) 2015-2021 by Peter Bartmann <> // // N64 RGB/YPbPr DAC is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public ...
// Copyright 1986-2016 Xilinx, Inc. All Rights Reserved. // -------------------------------------------------------------------------------- // Tool Version: Vivado v.2016.3 (win64) Build Mon Oct 10 19:07:27 MDT 2016 // Date : Thu Sep 21 11:58:18 2017 // Host : vldmr-PC running 64-bit Service Pack 1 ...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:100000000000000 ) using namespace std; int n, l[30], m[30], w[30]; int tw[30], P1, P2; map<pair<long long, long long>, pair<long long, long long> > mp; long long best = -(1ll << 58), msk1, msk2; void rec(int p, int msk, long long L, long long M, lon...
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { if (x < 0) return -x; return x; } template <class T> T sqr(T a) { return a * a; } const double pi = acos(-1.0); const double eps = 1e-8; int i, n, cnt; char s1[110], s2[110]; void fun1() { if (s1[i + 1]...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; string s; int pre[N], nxt0[N], now = 100002; int ans[N]; int n; void init() { vector<int> v; for (int i = n - 1; i >= 1; i--) { int p = s[i] - 0 ; int pos = upper_bound(v.begin(), v.end(), -p) - v.begin(); 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...
/** * 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> int main(void) { int n; char s[102]; scanf( %d n , &n); gets(s); if (s[0] == S && s[n - 1] == F ) { printf( YES ); } else { printf( NO ); } }
`default_nettype none module execute_forwarding_register( input wire iCLOCK, input wire inRESET, input wire iRESET_SYNC, //Writeback - General Register input wire iWB_GR_VALID, input wire [31:0] iWB_GR_DATA, input wire [4:0] iWB_GR_DEST, input wire iWB_GR_DEST_SYSREG, //Writeback - Stack Point Regis...
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 100; int f[N]; struct node { int u, v, w; bool operator<(const node& a) const { return w < a.w; } }; struct qq { int id, u, v, w; bool operator<(const qq& a) const { if (a.w == w) return id < a.id; return w < a.w; ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, k; cin >> n >> k; vector<long long> v; set<long long> s; map<long long, long long> m; for (long long i = 0; i < n; i++) { cin >> x; if (m[x] == 0) { m[x]++; v.insert(v.begin(), x); } ...
// -*- verilog -*- // Copyright (c) 2012 Ben Reynwar // Released under MIT License (see LICENSE.txt) // A qa_wrapper with a buffer_BB. module qa_wrapper #( parameter WDTH = 32 ) ( input wire clk, input wire reset, input wire [WDTH-1:0] in_data, input wire ...
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; const int CNTV = 105; const int LENSUFF = 11; const int K = 4; const int MOD = 1e9 + 9; struct node { int go[K], suff, p, pch, lev, cr; node() { memset(go, -1, sizeof go); suff = p = pch = cr = -1; lev = 0; ...
//====================================================================== // // tb_coretest_test_core.v // ----------------------- // Testbench for the coretest_test_core module. // // // Author: Joachim Strombergson // Copyright (c) 2014, Secworks Sweden AB // All rights reserved. // // Redistribution and use in sourc...
`timescale 1ns / 1ps `define NULL 0 `define abs(a) ((a)<0 ? -(a):(a)) // Engineer: Jose Fernando Zazo // Description: // Utility to replay a packets from a pcap file over a 64-bit for use in network test benches. // Based on the original work of Chris Shucksmith (https://github.com/shuckc/) module pcap_parse...
#include <bits/stdc++.h> using namespace std; const int maxn = 2000 + 5; const int MOD = 1000000000 + 7; int n, k; int a[maxn], e[maxn], s[maxn], t[maxn]; inline void mm(int a[], int b[]) { for (int i = 0; i < n; i++) { t[i] = 0; for (int j = 0; j <= i; j++) t[i] = ((long long)a[j] *...
#include <bits/stdc++.h> using namespace std; int a[200001]; int b[600001]; int n, L; bool chk(int d) { if (d * 2 >= L) return true; int l = 0, r = 3 * n - 1; while (b[l] < a[0] - d) l++; while (b[r] > a[0] + d) r--; for (int i = 1; i < n; i++) { l++; r++; while (b[l] < a...
#include <bits/stdc++.h> using namespace std; template <class T> void REV(T *a, int n) { reverse(a + 1, a + 1 + n); } template <class T> void SRT(T *a, int n) { sort(a + 1, a + 1 + n); } template <class T> int UNI(T *a, int n) { sort(a + 1, a + 1 + n); return unique(a + 1, a + 1 + n) -...
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 7; int n; int a[N], b[N], x[N], y[N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d%d , &a[i], &b[i]); } for (int i = 1; i <= n; i++) { scanf( %d%d , &x[i], &y[i]); } sort(a + 1, a + ...
// test_usb_ft232.v `timescale 1 ns / 1 ps module test_usb_ft232; reg clk = 0; reg reset = 1; // FT232 interface wire wr_n; wire rd_n; wire oe_n; wire [7:0]data; reg txe_n = 1; reg rxf_n = 1; wire siwu_n; // tx fifo interface wire tx_read; reg [15:0]tx_data = 16'hxx01; reg [1:0]tx_mask = 2'b01...
#include <bits/stdc++.h> using namespace std; int a[105]; struct Fenwick_Tree { int sz, c[305]; void init(int n) { sz = n; for (int i = 1; i <= n; i++) c[i] = 0; } int lowbit(int x) { return x & (-x); } void update(int p, int v) { for (int i = p; i <= sz; i += lowbit(i)) c[i]...
#include <bits/stdc++.h> using namespace std; int main() { int tt; cin >> tt; while (tt--) { int n, l; cin >> n >> l; vector<double> flags(n); for (auto& i : flags) cin >> i; double a_s = 0, b_s = l; double a_v = 1, b_v = 1; int a_i = 0, b_i = n - 1; doubl...
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int INF = 1e7; const long long Mod = 1e9 + 7; long long powmod(long long a, long long b) { long long res = 1; a %= Mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % Mod; a = a * a % Mod...
//+FHDR------------------------------------------------------------------------ //Copyright (c) 2013 Latin Group American Integhrated Circuit, Inc. All rights reserved //GLADIC Open Source RTL //----------------------------------------------------------------------------- //FILE NAME : //DEPARTMENT : IC Design / Veri...
#include <bits/stdc++.h> using namespace std; const int max_n = 1e5 + 10; const long long inf = 10000000000000000; vector<int> adj[max_n]; vector<long long> cst[max_n]; vector<int> arr[max_n]; vector<long long> closest[max_n]; void cmp_closest(int i) { int s = arr[i].size(); if (s > 0) { c...
#include <bits/stdc++.h> using namespace std; int main() { int s; cin >> s; int *a = new int[s]; for (int i = 0; i < s; i++) cin >> a[i]; for (int i = s - 2; i < s; i--) { if (a[i] != a[i + 1]) { cout << i + 1 << endl; break; } } return 0; }
// ------------------------------------------------------------- // // Generated Architecture Declaration for rtl of inst_t_e // // Generated // by: wig // on: Mon Jun 26 06:35:31 2006 // cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl ../../generic.xls // // !!! Do not edit this file! Autogenerated by MIX !!! // $Auth...
/** * 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, i, j, m, k; int a[2000000]; bool bo[2000000]; int l, r, ans, tot; int main() { scanf( %d%d%d , &n, &m, &k); for (i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + 1 + n); int now = 0; bo[0] = true; for (i = 1; i <= n; i++) { ...
// DESCRIPTION: Verilator: Verilog Test module // // This file ONLY is placed into the Public Domain, for any use, // without warranty. // bug1001 interface intf #(parameter PARAM = 0) (); logic val; endinterface module t(); generate if (1) begin intf #(.PARAM(2)) my_intf (); assi...
module bidir_switch_block( input [wire_width*wire_width*12-1:0] select, inout [wire_width-1:0] left, inout [wire_width-1:0] right, inout [wire_width-1:0] bottom ); parameter wire_width = 3; /*wire tb[2:0][2:0]; wire lr[2:0][1:0]; // First row bidir_switch bs1( .select(select[11:0]), .left(left[0]), ...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
#include <bits/stdc++.h> using namespace std; void chmax(int& a, int b) { a = max(a, b); } void chmin(int& a, int b) { a = min(a, b); } int nth_bit(int64_t num, int n) { return (num >> n) & 1; } int main() { string S; int X; cin >> S >> X; int N = S.size(); vector<int> A(N); for (int i...
/* Copyright (c) 2017 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 (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...
#include <bits/stdc++.h> using namespace std; template <class T> inline void amin(T &a, T b) { if (a > b) a = b; } template <class T> inline void amax(T &a, T b) { if (a < b) a = b; } int gcd(int x, int y) { while (y) { x %= y; swap(x, y); } return x; } int GCD[111][1...
/* * MBus Copyright 2015 Regents of the University of Michigan * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required ...
////////////////////////////////////////////////////////////////////////////// /// Copyright (c) 2014, Ajit Mathew <> /// All rights reserved. /// // Redistribution and use in source and binary forms, with or without modification, /// are permitted provided that the following conditions are met: /// /// * Redistribut...
/*------------------------------------------------------------------------------ * This code was generated by Spiral Multiplier Block Generator, www.spiral.net * Copyright (c) 2006, Carnegie Mellon University * All rights reserved. * The code is distributed under a BSD style license * (see http://www.opensource.or...
#include <bits/stdc++.h> using namespace std; const int N = 100010; const int S = 550; int n, q, a[N]; struct Block { int lid, rid; deque<int> que; int mp[N]; Block() {} void init() { lid = rid = 0; que.clear(); memset(mp, 0, sizeof mp); } void addf(int x) { ...
#include <bits/stdc++.h> using namespace std; int up[200005]; void init() { memset(up, -1, sizeof(up)); } int Find(int x) { if (up[x] < 0) return x; int root = Find(up[x]); up[x] = root; return root; } void Union(int x, int y) { x = Find(x); y = Find(y); if (x == y) return; i...
#include <bits/stdc++.h> using namespace std; int n; long long a[5005]; void input() { scanf( %d , &n); for (int i = 0; i < n; i++) { int x; scanf( %d , &x); a[i + 1] = a[i] + x; } } void solve() { long long outx, outy, outz, ans; ans = outx = outy = outz = 0; for (...
#include <bits/stdc++.h> unsigned long long c; int n, i, j, k, ks, ke, pd, pp, pa; char s[1000100]; bool f, ff, fff; int main() { scanf( %s , s); n = strlen(s); for (i = 0; i < n; i++) { if (s[i] >= a && s[i] <= z ) { k = 0, f = 1, ff = 0, fff = 0, ks = 1, ke = 0, pa = 0, pd = 0, ...
`default_nettype none module reservation_free_entry_count( input wire iINFO0, input wire iINFO1, input wire iINFO2, input wire iINFO3, input wire iINFO4, input wire iINFO5, input wire iINFO6, input wire iINFO7, input wire iINFO8, input wire iINFO9, input wire iINFO10, input wire iINFO11, in...
#include <bits/stdc++.h> using namespace std; long long mpow(long long a, long long b) { if (b == 1) return a; if (b == 0) return 1; return mpow(a, b - 1); } int main() { long long n; cin >> n; cout << (n / 2520); }
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int Mod = 1e9 + 7; const int Mod2 = 49157; const int p = 10; inline long long Read() { long long Ans = 0; char Ch = getchar(), Las = ; while (!isdigit(Ch)) { Las = Ch; Ch = getchar(); } while (isdigit...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> V; for (long long i = 1; i * i <= n; ++i) { if (!(n % i)) { V.push_back(i); V.push_back(n / i); } } sort(V.begin(), V.end()); for (long long i = V.size() - 1; i...
///////////////////////////////////////////////////////////////////////// // Copyright (c) 2008 Xilinx, Inc. All rights reserved. // // XILINX CONFIDENTIAL PROPERTY // This document contains proprietary information which is // protected by copyright. All rights are reserved. This notice ...
#include <bits/stdc++.h> using namespace std; int main() { int x; cin >> x; int k = x % 4; if (k == 1) { cout << 0 << A << endl; } else if (k == 0) { cout << 1 << A << endl; } else if (k == 2) { cout << 1 << B << endl; } else { cout << 2 << A << endl; ...
`define TAGSIM_LISTEN 3'b001 `define TAGSIM_MOD 3'b010 `define READER_LISTEN 3'b011 `define READER_MOD 3'b100 `define FAKE_READER 3'b101 `define FAKE_TAG 3'b110 `define READER_START_COMM_FIRST_CHAR 8'hc `define READER_END_COMM_1 16'h0000 `define READER_END_COMM_2 16'hc000 `define TAG_START_COMM_FIRST_CHAR ...
// ------------------------------------------------------------- // // File Name: mealy_rtl\Stateflow_Mealy_example\Mealy_Chart.v // // Generated by MATLAB 8.3 and HDL Coder 3.4 // // ------------------------------------------------------------- // ------------------------------------------------------------- // ...
// ---------------------------------------------------------------------- // Copyright (c) 2016, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met:...
#include <bits/stdc++.h> int main() { int i, gt = 0, arr[4]; char var = C ; char A[102]; for (i = 0; i < 4; i++) { scanf( %s , A); arr[i] = strlen(A) - 2; } for (i = 0; i < 4; i++) { if (i == 0) { if (arr[0] >= (2 * arr[1]) && arr[0] >= (2 * arr[2]) && ar...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int M = 1e7 + 1; ; const long long INF = 2e9 + 10; const long long MOD = 1000 * 1000 * 1000 + 7; const long double EPS = 1e-9; int a[N]; bool prime(int x) { for (int i = 2; i < (int)sqrt(x) + 1; ++i) if (x % i == 0) ...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const int INF = 0x7fffffff; const long long oo = 1e18; const int N = 106; const double pi = acos(-1.0); int n, ans = 1, now; char c; int main() { scanf( %d , &n); for (int i = 1; i < n; i++) { scanf( %c , &c); ...
#include <bits/stdc++.h> using namespace std; const int INF = 0x60000000; const int MINF = -1000000000; const int mod = 1000000007; const int cons = 100001; const double pi = 3.141592653589793; const int sqrtMax = 317; const int blocks = cons / 3; const int MOD = 100000; long long dp[1000001]; int...
// Copyright (c) 2000-2012 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, pub...
/******************************************************************************* * 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> int q, n; int main() { scanf( %d , &q); while (q--) { scanf( %d , &n); int b = sqrt(2 * n + 4); while ((b + 1) * (b + 2) / 2 > n) b--; int a = n - (b + 1) * (b + 2) / 2; printf( 133 ); for (int i = 1; i <= a; i++) printf( 7 ); for (int i = 1...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int x, y, n; cin >> x >> y >> n; int a, b; a = n % x; b = n - a; if (b + y <= n) { cout << b + y << endl; } else { cout << b + y - x << endl; } } ...
#include <bits/stdc++.h> using namespace std; template <class X, class Y> void amax(X& x, const Y& y) { if (x < y) x = y; } template <class X, class Y> void amin(X& x, const Y& y) { if (x > y) x = y; } const int INF = 1e9 + 10; const long long INFL = 1e18 + 10; const int MAX = 1e6 + 10; in...
#include <bits/stdc++.h> using namespace std; long double l[200006]; int main() { l[1] = 0; l[0] = 0; for (int i = 2; i < 200005; i++) { l[i] = log(i) + l[i - 1]; } int n, m, k; scanf( %d%d%d , &n, &m, &k); if (k >= m) { printf( 1.00000 n ); } else if (k + n < m) { ...
#include <bits/stdc++.h> using namespace std; long long h12, h13, h14, h23, h24, h34; long long k1, k2, k3; long long x1, x2, x3, x4, x5, x6, x7; long long min_x7, max_x7, best_x7; long long good = 0; long long len = -1; void fail() { printf( -1 n ); exit(0); } int main() { cin >> h12 >>...
#include <bits/stdc++.h> using namespace std; long long min(long long a, long long b) { return a < b ? a : b; } int ceil(int a, int b) { return (a + b - 1) / b; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k; cin >> n >> k; string s; cin >> s...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector<string> S(26); for (auto ch : s) { S[ch - a ] += ch; if (S[ch - a ].size() == 100) { cout << S[ch - a ] << endl; return 0; } } int n = s.size(); int f[n + 1][n + 1];...
// (c) Copyright 1995-2017 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 ...
/** * 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 = 2005; int n, a[N], s1[N], s2[N], ans = 0; void judge(int x, int y, int mid) { int tmp = 0; if (x == y) tmp = s1[mid] + s2[n] - s2[mid]; else tmp = s1[x - 1] + s2[n] - s2[y] + s2[mid] - s2[x - 1] + s1[y] - s1[mid]; ans = max(...
#include <bits/stdc++.h> using namespace std; int n, m, q; int x[1000][1000]; int r[1000][1000][4]; void upd1(int j) { int i = 0; for (int k = 0; k < n; ++k) { if (x[k][j] == 0) { i = k + 1; r[k][j][0] = -1; } else r[k][j][0] = i; } i = n - 1; for (int k...
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; int n[2], k[2]; string s[] = { First , Second }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n[0] >> n[1] >> k[0] >> k[1]; int cur = 0; while (1) { if (n[cur] == 0) break;...
#include <bits/stdc++.h> using namespace std; long long n, a, b, c, ans; int main() { cin >> n >> a >> b >> c; if (n >= b) ans = (n - ((n - b) / (b - c) + 1) * (b - c)) / a + (n - b) / (b - c) + 1; cout << max(n / a, ans); }
#include <bits/stdc++.h> int main() { int n, m; double resn, resm; scanf( %d%d , &n, &m); resn = m / (double)n; resm = log(m) / log(n); if (resn > resm) { printf( > n ); } else if (resn < resm) { printf( < n ); } else printf( = n ); return 0; }
//***************************************************************************** // (c) Copyright 2008 - 2010 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 /...
//---------------------------------------------------------------------------- // Copyright (C) 2014 , Atsushi Sasaki // // 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 re...
// place this file in testBench folder `timescale 1ns/100ps `define DEBUG 1 `include "../define.v" `include "../regfile.v" `include "../pipeline_CPU.v" `include "../hilo_reg.v" `include "../BranchControl.v" `include "../HazardControl.v" `include "../ForwardControl.v" `include "../IF.v" `include "../IF_ID.v" `include "....
#include <bits/stdc++.h> using namespace std; vector<int> get(int n) { if (n == 1) { return {1}; } if (n == 2) { return {3, 4}; } vector<int> a; if (n % 2 == 0) { int k = n / 2; for (int i = 1; i <= 2 * k - 1; i++) { a.push_back(1); } a.push_back(k...
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> t; int get(int a) { if (t[a] == a) { return a; } else { return t[a] = get(t[a]); } } struct kek { int a; int b; int c; }; bool operator<(kek a, kek b) { return a.c < b.c; } void uni(int a, int b) { ...
/** * 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; int sum[1010][1010]; char mp[1010][1010]; int getsum(int x1, int y1, int x2, int y2) { return sum[x1][y1] - sum[x2 + 1][y1] - sum[x1][y2 + 1] + sum[x2 + 1][y2 + 1]; } bool check(int a, int b, int x, int y) { while (1) { if (x + a - 1 > ...
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; for (int i = 0; i < q; ++i) { int n; cin >> n; vector<int> a(n); for (int j = 0; j < n; ++j) { cin >> a[j]; --a[j]; } int pos = 0; while (pos < n) { int nxt = min...
#include <bits/stdc++.h> using namespace std; template <class T, class U> void maximize(T &x, U y) { if (x < y) x = y; } template <class T, class U> void minimize(T &x, U y) { if (x > y) x = y; } template <class T> T Abs(T x) { return (x < (T)0 ? -x : x); } namespace task { const int...
/** * 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, K; int arr[205]; int u[100005], v[100005], f[100005]; int lvl[205], ptr[205]; bool vis[205]; vector<int> graph[205]; vector<int> cgraph[205]; vector<vector<int>> vec; void addedge(int a, int b, int k) { u[K] = a; v[K] = b; u[K ^ 1] = b...
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast,no-stack-protector ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; template <typename T> void read(T &a) { T x = 0, f = 1; char ch = getchar(); wh...
module hex_to_7seg ( input i_Clk, input [3:0] i_Value, output o_Segment_A, output o_Segment_B, output o_Segment_C, output o_Segment_D, output o_Segment_E, output o_Segment_F, output o_Segment_G ); reg [6:0] out = 7'b0000000; always @(pose...
#include <bits/stdc++.h> using namespace std; long long vec3[17][1 << 17]; long long mn(int i, int j) { int p = 31 - __builtin_clz(j - i); return min(vec3[p][i], vec3[p][j - (1 << p)]); } void mn_init(int n) { int mp = 31 - __builtin_clz(n); for (int p = 0; p < mp; ++p) for (int x = 0; x...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000005; int N, M, dp[MAXN], res = 0; vector<pair<int, int>> adj[MAXN]; int check(int v) { if (dp[v]) return dp[v]; dp[v] = 1; for (auto p : adj[v]) { int n = p.first; if (check(n) + 1 > dp[v]) { dp[v] = dp[n] + 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 law...
#include <bits/stdc++.h> const long long INF = 1e17, N = 2e5 + 1; using namespace std; int a[N], n, m, k, sum[N], t[N]; int getime(int idx) { return min(idx, n - idx + 1); } int getlen(int l, int r) { if (l > r) swap(l, r); int tmp = (r - l) / m; if ((r - l) % m != 0) tmp++; return tmp; } ...
//-------------------------------------------------------------------------------- // receiver.vhd // // Copyright (C) 2006 Michael Poppitz // // 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;...
#include <bits/stdc++.h> using namespace std; string second[100]; int x[100], y[100]; vector<int> a, b; bool u[100][100]; bool uu[100][100]; bool ux[100], uy[100]; int n, m; void dfs(int x, int y) { ux[x] = uy[y] = true; u[x][y] = true; for (int i = 0; i < n; i++) if (second[i][y] ==...
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 555; long long saveori[maxn]; long long savepos[maxn]; long long tree[maxn << 2]; void update(long long nowid, long long l, long long r, long long pos, long long v) { if (l == r) { tree[nowid] = v; return; ...
/** * 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() { long long i, n, lns, t = 0, pos = -1, posl = 0; string s, ot; cin >> s; lns = s.length(); ot.clear(); for (i = 0; i < lns; ++i) { if (s[i] == a ) t++; else posl++; } if (t == lns) { cout << ...
#include <bits/stdc++.h> using namespace std; const double pi = 3.141592653589793; const int INF = 2000000000; const int mod = 1000000007; const int N = 100000000; const int base = 10; vector<int> read(string s) { vector<int> a; for (int i = (int)s.length(); i > 0; i -= 1) if (i < 1) ...