text
stringlengths
59
71.4k
#include <bits/stdc++.h> const int N = 100010; const int M = 30; std::map<std::string, int> Hash; int fa[N << 1], n, m, q; char s[M]; int find(int u) { return fa[u] == u ? u : fa[u] = find(fa[u]); } void unite(int u, int v) { int _u = find(u), _v = find(v); fa[_u] = _v; find(u); } int 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 law...
#include <bits/stdc++.h> using namespace std; int n, ar[200001], f[10001], g[21][21], f1[10001]; int main() { ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL); cin >> n; for (int i = 0; i < n * n; i++) { cin >> ar[i]; f[ar[i]]++; f1[ar[i]]++; } if (n & 1) { int wh...
/* * Milkymist SoC * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq * * 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 distribut...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/** * Copyright 2020 The SkyWater PDK Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable la...
/* * Copyright (c) 2001 Stephan Boettcher <> * * 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; int n, q; int a[1000007]; int st[1000007]; int en[1000007]; vector<pair<int, int> > v_st[1000007]; long long ans[1000007]; class Tree { public: pair<long long, int> tr[6 * 1000007]; void init(int where, int IL, int IR) { tr[where] = {0, 0}; ...
#include <bits/stdc++.h> using namespace std; const double INF = 1000000000; struct point { long long x, y; point() {} point(long long x, long long y) : x(x), y(y) {} point operator-(point P) { return point(x - P.x, y - P.y); } }; double abs(point P) { return sqrt(P.x * P.x + P.y * P.y); } d...
#include <bits/stdc++.h> using namespace std; int main() { long long int t = 1; while (t--) { long long int n; cin >> n; cout << 0 << << 0 << << n; } }
#include <bits/stdc++.h> using namespace std; int main() { double a, b, c, d; cin >> a >> b >> c >> d; double mx; mx = (a / b) * (1 / (1 - (1 - a / b) * (1 - c / d))); std::cout << std::setprecision(9) << mx << n ; }
#include <bits/stdc++.h> using namespace std; const int M = 3000; int n, m; pair<pair<int, int>, int> v[M]; map<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int> > > Q; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } pair<pair<int, int>, int> get(int x1, int y1, int x2, int y2) { in...
#include <bits/stdc++.h> using namespace std; const int max_n = 100000; int n, k; char s[max_n + 5]; void solve(void); int main(void) { int t; scanf( %d , &t); while (t--) solve(); return 0; } void solve(void) { scanf( %d%d , &n, &k); scanf( %s , s); int i, j, t, ans = 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 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; const int N = 1e5 + 5; int n, m, k, ans[5]; char s[N]; void solve(int l, int r) { while (l != r) { int mid = l + r >> 1; printf( 1 %d %d n , mid, mid + 1); fflush(stdout); scanf( %s , s); if (!strcmp(s, NIE )) l = mid + 1...
/* SRAM implementation * * Implements an SRAM with each entry holding eight bits and eight entries * total. * * Created By David Tran * Version 0.1.0.0 * Last Modified:05-01-2014 */ module SRAM(read, // Specifies if we want to read from the FIFO write, // Specifies if we want to write form the...
// 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 13 12:43:59 2017 // Host : WK117 running 64-bit major release (build ...
// file: clk_divider_tb.v // // (c) Copyright 2008 - 2011 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 n...
/** * 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; const int N = 1e5 + 10; int n, m, a[N]; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.setf(ios::fixed), cout.precision(9); cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i]; a[n + 1] = m; vector<int> pf...
#include <bits/stdc++.h> using namespace std; int main() { string s; long long t, j = 0; cin >> t; cin >> s; for (long long i = 0; i < s.size(); i++) { if (s[i] == F ) if (s[i + 1] == S ) j--; if (s[i] == S ) if (s[i + 1] == F ) j++; } if (j <= 0) co...
#include <bits/stdc++.h> using namespace std; int main() { int h, m; while (scanf( %d:%d , &h, &m) == 2) { int a; scanf( %d , &a); int t = (h * 60 + m + a) % (24 * 60); printf( %02d:%02d n , t / 60, t % 60); } }
#include <bits/stdc++.h> using namespace std; const int maxn = 1000000 + 50; const int maxm = 1300000 + 100; const int maxt = 3000000 + 100; const int maxk = 10 + 3; const int M = 2010; const long long unit = 1LL; const int INF = 0x3f3f3f3f; const long long Inf = 0x3f3f3f3f3f3f3f3fLL; const double e...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 10; const long long M = 1e7 + 1000; const long long mod = 1e9 + 7; const long long INF = 1e18; const long long inf = -1e18; bool isprime(long long x) { if (x == 1) return false; long long y = sqrt(x); for (int i = 2; i <= ...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 1e6 + 10; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; inline int read() { static char buf[1000000], *p1 = buf, *p2 = buf; register int x = false; register char ch = p1 == p2 &&...
module var17_multi (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, valid); input A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q; output valid; wire [8:0] min_value = 9'd120; wire [8:0] max_weight = 9'd60; wire [8:0] max_volume = 9'd60; wire [8:0] total_value = A * 9'd4 + B *...
#include <bits/stdc++.h> using namespace std; vector<long long> ve[100005]; long long vis[100005] = {0}, z = 0, i; void solve() { vector<long long> v; vector<pair<long long, long long> > vp; map<long long, long long> mp, mpp; map<long long, long long>::iterator itr; long long n = 0, m = 0, i...
// 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...
#include <bits/stdc++.h> using namespace std; int const N = 1e5 + 2; int n, m; void solve() { string n, m; cin >> n >> m; sort((n).begin(), (n).end()); if (n[0] == 0 && n.size() > 1) swap(n[0], n[1]); if (n == m) cout << OK << endl; else cout << WRONG_ANSWER << 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 law...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long power(long long a, long long b) { long long ret = 1; while (b) { if (b & 1) ret *= a; a *= a; if (ret >= MOD) ret %= MOD; if (a >= MOD) a %= MOD; b >>= 1; } return ret; } long l...
/* * 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 law...
// megafunction wizard: %ROM: 1-PORT%VBB% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: CoarseDelay.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // ============...
// generated by gen_VerilogEHR.py using VerilogEHR.mako // Copyright (c) 2019 Massachusetts Institute of Technology // 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...
(* We want a dependently typed recursive function. The output type is itself described by a recursive function. *) Fixpoint bool_nat_type (n:nat) : Set := match n with 0 => nat | 1 => bool | S (S n) => bool_nat_type n end. (* The difficult point is to describe the computation at each recursive step, knowing t...
#include <bits/stdc++.h> int n; int main() { while (EOF != scanf( %d , &n)) { if (n == 5) printf( 1 n ); else printf( %d n , n % 3 + 1); } return 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; const long double epsilon = 1e-9; string minus1(const string& str) { string str1(str); for (int i = str.size() - 1; i >= 0; i--) { if (str1[i] != 0 ) { str1[i]--; break; } else str1[i] = 9 ; } return str1; } lo...
#include <bits/stdc++.h> using namespace std; int n, k, a[100005], vis[100005], cnt, t; void Solve() { scanf( %d %d , &n, &k); for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); if (!vis[a[i]]) cnt++; ++vis[a[i]]; if (cnt == k) { t = 1; while (cnt == k) { ...
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long q; cin >> q; while (q--) { long long n; cin >> n; vector<long long> vec(n, 0); vector<bool> vis(n, false); vector<pair<long long, long...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n; while (n--) { cin >> m; if (m % 2 == 1) cout << (m + 1) / 2 << endl; else cout << 1 + m / 2 << endl; } }
module etx(/*AUTOARG*/ // Outputs txo_lclk_p, txo_lclk_n, txo_frame_p, txo_frame_n, txo_data_p, txo_data_n, txrd_wait, txwr_wait, txrr_wait, etx_cfg_access, etx_cfg_packet, // Inputs etx_reset, sys_reset, sys_clk, tx_lclk, tx_lclk90, tx_lclk_div4, txi_wr_wait_p, txi_wr_wait_n, txi_rd_wait_p, txi_rd...
#include <bits/stdc++.h> using namespace std; int D[100010]; int TN[100010]; vector<int> G[100010]; vector<int> T[100010]; vector<long long int> TS[100010]; map<int, double> S[100010]; struct Furthest { int s, t, x, maxl, N; void DFS1(int u, int f, int l) { if (l > maxl) { x = u; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, s; cin >> n >> s; int a[n + 1]; int cnt = 0; for (int i = 1; i < n; ++i) { a[i] = 1; cnt++; } a[n] = s - cnt; s -= cnt; if (s - cnt < 2) { cout << NO << endl; } else { cout << YES <<...
#include <bits/stdc++.h> using namespace std; const int N = 100; int l[N], r[N], t[N], c[N]; int main() { int n, m; scanf( %d %d , &n, &m); for (int i = 0; i < m; ++i) { scanf( %d %d %d %d , l + i, r + i, t + i, c + i); } int ans = 0; for (int i = 1; i <= n; ++i) { int win = ...
#include <bits/stdc++.h> using namespace std; const int N = 100010; const int M = 310; int n, m, s, e0, E; pair<int, int> dp[N][M]; int a[N]; vector<int> elAtB[N]; inline int findj(int j0, int val) { if (j0 >= m) return -1; vector<int> &v = elAtB[val]; if (v.size() == 0) return -1; vecto...
#include bits/stdc++.h using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; #define int ll #define sz(a) int(a.size()) #define dbg(a) cout << #a << = << a << endl #define dbg1(a) cout << #a << = [ ; for (auto& _ : a) cout << _ << ; cout << ] <<...
#include <bits/stdc++.h> int find_min(int pos, int target) { int right = -1; for (int i = 0; right == -1; i++) if ((pos + i) % 26 == target) right = i; int left = -1; for (int i = 0; left == -1; i++) if ((pos - i + 26 * 2) % 26 == target) left = i; return std::min(right, left); } i...
#include <iostream> #include <algorithm> using namespace std; int main() { int64_t k; int64_t n, x, t; cin >> k; while(k--) { cin >> n >> x >> t; int64_t zero = 0; int64_t ans = max(zero, n - t/x) * (t / x) + min(t/x, n) * min(t/x - 1, n - 1) / 2; ...
/* * Wishbone Flash RAM core for Altera DE2 board (90ns registered) * Copyright (c) 2009 Zeus Gomez Marmolejo <> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Fre...
#include <bits/stdc++.h> using namespace std; bool compa(int i, int j) { return i > j; } long long int power(long long int a, long long int n) { if (n == 0) return 1; else if (n % 2) { long long int d1 = power(a, n / 2); return d1 * d1 * a; } else { long long int d1 = power(a, ...
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0, t = 0; string road; cin >> n >> road; for (int i = 1; i < n; ++i) { if (road[i] == L ) { t = i; for (int j = i + 1; j < n; ++j) { if (road[j] == . ) { s = j; break; ...
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, k; cin >> n >> k; if (k > n) cout << -1 << n ; else if (n != 1 && k == 1) cout << -1 << n ; else if (k == n) { char x = a ; for (long long int i = 1; i <= (long long int)n; i++) { c...
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 15:50:04 07/21/2014 // Design Name: // Module Name: divider // Project Name: // Target Devices: // Tool versions: // Description: // // Dependencies: // //...
#include <bits/stdc++.h> using namespace std; const double eps = 1E-9; const double Exp = 2.718281828459045; const double pi = 3.14159; const double E = 2.7182818284590452354; int isRight(int x1, int x2) { if (x1 < x2) return 1; else return -1; } int main() { int arr[3][2]; f...
/* * 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; unordered_set<int> S; int main() { int n; cin >> n; int A[n], dp[n + 1]; dp[0] = 0; S.clear(); for (int _n{n}, i{0}; i < _n; ++i) { cin >> A[i]; dp[i + 1] = dp[i]; if (!S.count(A[i])) { S.insert(A[i]); dp[i + 1...
// UC Berkeley CS251 // Spring 2018 // Arya Reais-Parsi () // Stage #1: Fetch and Decode. `include "const.vh" module FetchDecodeStage #( parameter ADDR_LEN = `CPU_ADDR_BITS )( input wire clk, input wire reset, // This is the address presented to the instruction memory. We expect it to // take 1 cycle to re...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int ans = 1; if (a > b) { for (int i = b; i >= 1; i--) { ans *= i; } } else { for (int i = a; i >= 1; i--) { ans *= i; } } cout << ans; return 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; struct data { int id, a; data() {} data(int id, int a) : id(id), a(a) {} bool operator<(const data &r) const { return a < r.a; } } da[100010]; int n, h; int main() { scanf( %d%d , &n, &h); for (int i = 0; i < n; i++) scanf( %d , &da[i].a), ...
#include <bits/stdc++.h> using namespace std; long long T, W, B, H, P; long long fpb(long long A, long long B) { if (A == 0) { return B; } return fpb(B % A, A); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> T >> W >> B; H = W / fpb(W, B); ...
/* Copyright (c) 2014 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,...
// megafunction wizard: %ROM: 1-PORT% // GENERATION: STANDARD // VERSION: WM1.0 // MODULE: altsyncram // ============================================================ // File Name: bg.v // Megafunction Name(s): // altsyncram // // Simulation Library Files(s): // altera_mf // =====================================...
#include <bits/stdc++.h> int ans = 2, n, t; double m; struct T { int x, t; } a[1111]; bool my(T a, T b) { return (a.x < b.x); } int main() { scanf( %d%d , &n, &t); for (int i = 1; i <= n; i++) scanf( %d%d , &a[i].x, &a[i].t); std::sort(a + 1, a + n + 1, &my); for (int i = 2; i <= n; i++)...
#include <bits/stdc++.h> using namespace std; const int Maxn = 4010; double num1[Maxn]; int num2[Maxn]; double dif[Maxn]; int main() { int n = 0, N = 0; int cnt = 0, cnt1 = 0, cnt2 = 0; double sum = 0; double ans = 100000000.0; scanf( %d , &n); N = 2 * n; for (int i = 0; i < N; i...
#include<bits/stdc++.h> #include<algorithm> #define ll long long using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int testcases; cin>>testcases; while(testcases--){ int n,k; cin>>n>>k; unsigned ll sum = 0 ; cin>>sum; ...
#include <bits/stdc++.h> using namespace std; using namespace std; using ll = long long; using ld = long double; const int MOD = 1e9 + 7, inf = 1e9, N = 2e5 + 1; const ll INF = 1e18; ld tic, tac; void solve() { string str, ans = ; cin >> str; int cr = 0, cs = 0, cp = 0; for (int i = 0;...
#include <bits/stdc++.h> #pragma gcc optimize(O3) using namespace std; long long INF = static_cast<long long>(2e18); long long inf = static_cast<long long>(1e9 + 7); long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } vector<vector<set<long long> > > dp; int main() { ios_base::sy...
`timescale 1ns / 1ns `default_nettype none ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 02:28:18 02/06/2014 // Design Name: // Module Name: test1 // Project Name: // Target Devices: // Tool versions: // Description: // //...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int count1 = 0; for (int i = 0; i < n; i++) { int sum = 0; for (int j = 0; j < n; j++) { if (i == j) { continue; ...
/* * 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...
module arbiter( // Inputs input_arry, issued_en, issued_wf_id, // Outputs choosen_valid, choosen_wf_id, clk, rst ); input clk,rst; input issued_en; input[5:0] issued_wf_id; input[39:0] input_arry; output choosen_valid; output[5:0] choosen_wf_id; wire[5:0] last_issued_wf_...
/* * 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...
module top( input PACKAGEPIN, output [1:0] PLLOUTCORE, output [1:0] PLLOUTGLOBAL, input EXTFEEDBACK, input [7:0] DYNAMICDELAY, output LOCK, input BYPASS, input RESETB, input LATCHINPUTVALUE, //Test Pins output SDO, ...
`timescale 1ns / 1ps //////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 17:36:16 10/29/2011 // Design Name: M_uxa_ps2_shfreg // Module Name: /Users/kc5tja/tmp/kestrel/2/nexys2/uxa/ps2io/T_uxa_ps2_shfreg.v // Project Name: ps2io // 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 law...
#include <bits/stdc++.h> using namespace std; inline int in() { int x; scanf( %d , &x); return x; } template <typename T> inline istream& operator>>(istream& i, vector<T>& v) { for (int j = 0; j < ((int)(v).size()); ++j) i >> v[j]; return i; } template <typename T> string join(const ...
#include <bits/stdc++.h> using namespace std; int a, b, n, i, j; int f[5001]; int dp[5001][5001]; char s[5003]; int main() { while (~scanf( %d%d%d , &n, &a, &b)) { scanf( %s , &s[1]); for (i = 1; i <= n; i++) f[i] = f[i - 1] + a; for (i = 1; i <= n; i++) { f[i] = min(f[i], f[i ...
// ---------------------------------------------------------------------- // Copyright (c) 2015, 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> using namespace std; bool comp(pair<long long, long long> &p1, pair<long long, long long> &p2) { if (p1.first == p2.first) { return p1.second < p2.second; } else { return p1.first < p2.first; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL...
# include <bits/stdc++.h> using namespace std; const int N=1e3+10; int n,m,a[N][N],sum1[N],sum2[N],c1[N],c2[N],c3[N]; map<int,int>mp,tt; signed main() { scanf( %d%d ,&n,&m); for (int i=1;i<=m;i++) for (int j=1;j<=n;j++) { scanf( %d ,&a[i][j]); sum1[i]+=a[i][j]; sum2[i]+=a[i][j]*a[i...
/* This file is part of JT51. JT51 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. JT51 is distributed in the hope tha...
#include <bits/stdc++.h> using namespace std; int main() { int w, h; cin >> w >> h; int u1, d1, u2, d2; cin >> u1 >> d1 >> u2 >> d2; for (int i = h; i >= 0; i--) { w = w + i; if (i == d1 || i == d2) { if (i == d1) { w = w - u1; if (w < 0) { w =...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int tree[N << 2], Max[N << 2], Min[N << 2], cnt; bool fu[N << 2]; pair<int, int> a[N]; void build(int l, int r, int rt) { if (l == r) { tree[rt] = a[l].first; Max[rt] = Min[rt] = tree[rt]; return; } int m = (l...
#include <bits/stdc++.h> using namespace std; int n, a[200005], sum; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i], sum ^= a[i]; if (n % 2 == 0) { if (sum) { puts( NO ); return 0; } n--; } puts( YES ); printf( %d n , n - 1); for (int ...
#include <bits/stdc++.h> using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int main() { fastio(); long long int a, b; long long int mx = INT_MIN; long long int n, mn = INT_MAX; cin >> n; long long int ar[n]; for (int i = 0; ...
#include <bits/stdc++.h> template <typename T> T sqr(T x) { return x * x; } template <typename T> bool exmax(T &a, T b) { return (b > a) ? (a = b) || 1 : 0; } template <typename T> bool exmin(T &a, T b) { return (b < a) ? (a = b) || 1 : 0; } using namespace std; int a[510], b[510], l; ...
/** * 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...
// Fast Multisource Pulse Registration System // Module: // Flexible, 3-fifo multidirectional FX2 USB-2 interface // (c) Ben Gamari (2010) module reg_manager( clk, cmd_wr, cmd_in, reply_out, reply_rdy, reply_ack, reply_end, reg_addr, reg_data, reg_wr ); // fx2bidir interface input clk; input cmd_...
// 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; // verilator lint_off LITENDIAN // verilator lint_off BLKANDNBLK // 3 ...
/* Author: Sanskar Agarwal Nick: sanskaragarwal Birla Institute Of Technology, Mesra */ #include <bits/stdc++.h> using namespace std; #define ll long long int #define endl n #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++) #def...
#include <bits/stdc++.h> using namespace std; char b[1000050], a[1000050]; int n, m, p, P; bool c[2050], ans[2050], Ans; bool Calc(int x, int y, int z, int o, int u) { for (; o >= z; o--) { bool Flag = false; while (y >= x) { bool flag = true; for (int j = y, k = o; j <= n && 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; bool prime(long long n) { for (long long i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } int main() { long long n, ans; cin >> n; if (prime(n)) ans = 1; else if (n % 2 == 0) ans = 2; else if ...
#include <bits/stdc++.h> long long int add(long long int a, long long int b) { return a + b - (a + b >= 1000000007) * 1000000007; } long long int sub(long long int a, long long int b) { return a - b + (a - b < 0) * 1000000007; } long long int mult(long long int a, long long int b) { return (1LL * ...
#include <bits/stdc++.h> const int maxn = 3e5 + 7; int ch[maxn << 5][2], max[maxn << 5], n, q, k, l[maxn], r[maxn], id[maxn], rk[maxn], a, b, x, y, tl, rt[maxn]; int cmp(int x, int y) { return r[x] < r[y]; } int insert(int rt, int L, int R, int p, int v) { int nrt = ++tl; ch[nrt][0] = ch[rt][0]; ...