text stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int MAXN = (int)1e5 + 10; int n, cnt = 0; string a, b; void check(string a, string b) { int p = 0; for (; p < ((int)(a).size()) && a[p] == b[p]; ++p) ; if (a.substr(0, p) == b.substr(0, p) && a.substr(p) == b.substr(p + 1)) ++cnt; } int... |
//=============================================================
//
// Copyright (c) 2017 Simon Southwell. All rights reserved.
//
// Date: 22nd May 2017
//
// This code 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 So... |
#include <bits/stdc++.h> using namespace std; bool isvowel(char c) { c = tolower(c); return (c == a || c == e || c == i || c == o || c == u ); } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return (... |
#include <bits/stdc++.h> using namespace std; inline void FAST_IO() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } template <class F, class S> ostream& operator<<(ostream& os, pair<F, S>& p) { os << ( << p.first << , << p.second << ) ; return os; } template <class T, class ... |
module SmallHpf2nd_tb ();
parameter K0_SHIFT = 6; ///< K0 filter term = 2^-K0_SHIFT
parameter K1_SHIFT = 6; ///< K1 filter term = 2^-K1_SHIFT
parameter WIDTH = 16; ///< Width of data path
parameter CLAMP = 1; ///< Set to 1 to clamp the accumulators
parameter FREQ_RATE = ;
reg clk;
reg rst;
reg en;
reg signed [W... |
#include <bits/stdc++.h> using namespace std; int n, ls[310]; int dp[110][310][310]; pair<int, int> p[110]; int L[110], R[110], x[110]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d%d , &p[i].first, &p[i].second); ls[i * 3 - 2] = p[i].first - p[i].second; l... |
#include <bits/stdc++.h> using namespace std; int N, M; int d[300010]; int h[300010]; pair<long long, int> L[8 * 300010]; pair<long long, int> R[8 * 300010]; void aggL(int nodo, int left, int right, int pos, long long val) { if (left == right) { L[nodo] = pair<long long, int>(val, pos); re... |
//-----------------------------------------------------------------------------
//
// (c) Copyright 2009-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 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; long long cnt[5], ans1, ans2; int main() { int n, a[200010]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] == 1) cnt[1]++; else cnt[0]++; } for (int i = 0; i < n; i++) { if (a[i] == 0) ... |
`timescale 1ns / 1ns
`define HALT 5'b0_0000
`define EXEC 3'b100
`define EAD 3'b010
module opc8tb( ) ;
reg [23:0] mem [ 16777215:0 ];
reg clk, reset_b, interrupt_b, int_clk, clken;
wire [23:0] addr;
wire [23:0] data1;
wire rnw, vda, vpa;
wire ceb = 1'b0;
wire oeb =... |
/**
* 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; vector<long long unsigned> p_pow; vector<long long unsigned> reverse_p_pow; const int hash_base = 31; long long unsigned binpow(long long unsigned a, long long unsigned n) { long long res = 1; while (n) { if (n & 1) res *= a; a *= a; n >>... |
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 14:04:52 01/04/2013
// Design Name: ctrl_reg_readback
// Module Name: H:/Firmware/FONT5_base/ISE13/FONT5_base/ctrl_reg_rb_tb.v
// Project Name: FONT5_base
// Target ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long f = 1, sum = 0; char c = getchar(); while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) { sum = sum * 10 + c - 0 ; c = getchar(); } return sum * f; } ... |
#include <bits/stdc++.h> using namespace std; const int max_n = 5005, inf = 1011111111; int n, p[max_n], b[max_n]; int pos[max_n]; vector<pair<vector<int>, pair<vector<int>, vector<int>>>> all; vector<pair<vector<int>, pair<vector<int>, vector<int>>>> my_all; void find_b() { for (int i = 0; i < n; ++i... |
#include <bits/stdc++.h> using namespace std; const int maxm = 1e6 + 5; double q[maxm]; int buf[maxm], len[maxm]; void run_case() { int n; cin >> n; int top = 0; for (int i = 1; i <= n; ++i) cin >> buf[i]; q[++top] = buf[1], len[1] = 1; for (int i = 2; i <= n; ++i) { double now =... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m, x, y, i; cin >> n >> m >> x >> y; cout << x << << y << endl; int k = x + 1; int p = x - 1; for (i = 1; i < m + 1; i++) { if (i != y) cout << x << << i << endl; } int jj = 1; while (k <= n) { ... |
module echo #(parameter freq = 50_000_000) (
input wire clk,
input wire rst_n,
// to CoreUART
input wire rxrdy,
input wire txrdy,
input wire[7:0] data_out,
output wire oen,
output wire wen,
o... |
//////////////////////////////////////////////////////////////////////
//// ////
//// OR1200's IC TAGs ////
//// ////
//// This file is part of the OpenR... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:100000000000,100000000000 ) using namespace std; const long long inf = 1e18 + 7; const long long mod = 1e9 + 7; const double eps = 1e-12; const double PI = 2 * acos(0.0); const double E = 2.71828; int n; long long a[1000005]; long long d[10000... |
/******************************************************************************
* License Agreement *
* *
* Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. *
... |
/*
########################################################################
ELINK TX CONFIGURATION REGISTER FILE
########################################################################
*/
`include "elink_regmap.v"
module etx_cfg (/*AUTOARG*/
// Outputs
mi_dout, tx_enable, mmu_enable, gpio_enable, remap_enab... |
// -------------------------------------------------------------
//
// Generated Architecture Declaration for rtl of cpu
//
// Generated
// by: wig
// on: Mon Jun 26 16:38:04 2006
// cmd: /cygdrive/h/work/eclipse/MIX/mix_0.pl ../nreset2.xls
//
// !!! Do not edit this file! Autogenerated by MIX !!!
// $Author: wig ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, step, smallest, count = 0; bool possible = true; cin >> n >> step; vector<long long> p(n); cin >> p[0]; smallest = p[0]; for (int i = 1; i < n; i++) { cin >> p[i]; if (p[i] < smallest) { smallest ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, s, f; cin >> n >> m >> s >> f; map<int, pair<int, int> > mop; for (int i = 0; i < m; i++) { int t, l, r; cin >> t >> l >> r; mop[t] = {l, r}; ... |
#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 = ... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
// megafunction wizard: %RAM: 1-PORT%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: altsyncram
// ============================================================
// File Name: StackRAM.v
// Megafunction Name(s):
// altsyncram
//
// Simulation Library Files(s):
// altera_mf
// ===============================... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, p, i, j, val, sum = 0, ans = 0; scanf( %lld %lld , &n, &p); long long int a[n]; for (i = 0; i < n; i++) { scanf( %lld , &a[i]); sum += a[i]; } sum %= p; val = 0; for (i = 0; i < n - 1; 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... |
// (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 ... |
// 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... |
`timescale 1ns / 1ps
module Main(
input clk50mhz,
output [5:0] RGB,
output hsync,
output vsync,
input clk_audio,
input right_button,
input reset_button,
input start_button,
input left_button,
output [3:0] tono
);
//VGA section
wire vga_clk;
wire clk_paddle;
wire clk_ball;
wire [5:0] rgb;
... |
`timescale 1ns / 1ps
module RegisterFileSim();
reg clk;
reg init;
reg [4:0] readReg1;
reg [4:0] readReg2;
reg [4:0] writeReg;
reg writeOp;
reg [31:0] writeData;
wire [31:0] readData1;
wire [31:0] readData2;
RegisterFile file(
.clk(clk),
.init(init),
.wr... |
/**
* 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 f[200010], fi[200010]; const int MOD = 1e9 + 7; int add(long long a, long long b) { return (a + b) % MOD; } int mul(long long a, long long b) { return (a * b) % MOD; } int fp(long long a, int b) { if (b == 0) return 1; int tp = fp(a, b >> 1); tp ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int s, v = 0; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = 0; i < n - 1; i++) { if (arr[i] > arr[i + 1]) { s = i + 1; v++; } } if (arr[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 la... |
`default_nettype none
`timescale 1ns / 1ps
module mmu(
input wire clock,
input wire reset,
// CPU
input wire [15:0] A_cpu,
input wire [7:0] Di_cpu, // should be Do from cpu
output wire [7:0] Do_cpu, // should be mux'd to cpu's Di
input wire rd_cpu_n,
input wire wr... |
#include <bits/stdc++.h> using namespace std; int n; int a[15]; void f(int fg, int x) { if (fg == 1) { for (int i = 0; i <= 10; i++) { if (((x >> i) & 1) != 0) { a[i] = 1; } } } else if (fg == 2) { for (int i = 0; i <= 10; i++) { if (((x >> i) & 1) == ... |
#include <bits/stdc++.h> using namespace std; vector<int> sol; int n, m, T, h, mi, cnt, fndm, v[1000100], sec; char ch; int main() { cin >> n >> m >> T; for (int i = 1; i <= n; ++i) { cin >> h; cin >> ch; h *= 3600; cin >> mi; cin >> ch; mi *= 60; cin >> sec; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, inf = 1e9; int n; int a[maxn]; int main() { cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + 1 + n); long long lsum = 0, rsum = 0; for (int i = 1; i <= n / 2; ++i) lsum += a[i]; for (int i = n /... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 100; const int LVL = 18; int n, m; int a[N]; int b[N]; int c[N]; int h[N]; int inplace[N], parent[N]; int inmst[N]; int dp[N][LVL], mini[N][LVL], maxi[N][LVL]; int ans[N]; vector<int> tree[N]; int find(int node) { if (pare... |
#include<bits/stdc++.h> using namespace std; int a[305]; int main() { int t; cin>>t; while(t--) { int n,x; cin>>n; string s; cin>>s; bool flag=false; if(s== 2020 ) flag=true; else { ... |
// ***************************************************************************
// ***************************************************************************
// Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved.
//
// In this HDL repository, there are many different and unique modules, consisting
// of... |
#include <bits/stdc++.h> using namespace std; using cat = long long; struct edge { int u, v, id; }; int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); int N, M, K; cin >> N >> M >> K; vector<int> W(N), D(N, 0); for (int i = 0; i < N; i++) cin >>... |
// megafunction wizard: %FIFO%
// GENERATION: STANDARD
// VERSION: WM1.0
// MODULE: dcfifo_mixed_widths
// ============================================================
// File Name: txfifo_512x72_to_9.v
// Megafunction Name(s):
// dcfifo_mixed_widths
//
// 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; #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) const long long maxn = 1e5 + 10, LG = 30, mod = 1e9 + 7, inf = 1e18; long long n, m, f[maxn]; vector<long long> in[maxn], out[maxn]; bool mk[maxn], km[maxn]; void dfs(long long v) { mk[v]... |
// (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 ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; long long mod = 1e18; long long fast_pow(long long b, long long p) { if (p == 0) return 1; long long m = fast_pow(b, p / 2); m = ((m % mod) * (m % mod)) % mod; if (p % 2 == 1) m = ((m % mod) * (b % mod)) % mod; return m; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const double pi = acos(-1); map<int, int> p; int a[300010], l[300010], r[300010]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); int ans = 0; l[ans] = 1; p[a[1]]++; for (... |
#include <bits/stdc++.h> const int MAXN = 2e5 + 10; int n; int a[MAXN], b[MAXN]; namespace bit { int a[MAXN]; void init() { std::fill(a + 1, a + n + 1, 0); } void add(int x, int y) { for (; x <= n; x += x & (-x)) { a[x] += y; } } int query(int x) { int ans = 0; for (; x > 0; x -=... |
/*
* yosys -- Yosys Open SYnthesis Suite
*
* Copyright (C) 2021 Cologne Chip AG <>
*
* 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.... |
/**
* tb-utils.v - Provides a set of useful Verilog testbench macros.
*
* Verilib - A Verilog HDL development framework
* Copyright (c) 2014, Patrick Dear, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* Licens... |
`timescale 1ns / 1ps
`default_nettype none //To avoid bugs involving implicit nets
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Acknowledgements: Prof. Kyle Gilsdorf (Arizona State)
// - http://www.public.asu.edu/~kyle135/
// -
//
//
//... |
#include <bits/stdc++.h> using namespace std; vector<int> graf[1000001]; vector<int> chains[1000001]; vector<int> chainsbit[1000001]; int chainwhere[1000001], chainposition[1000001]; void update(int chainidx, int x, int val) { while (x <= chainsbit[chainidx].size() - 1) { chainsbit[chainidx][x] +=... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int cnt[maxn], num[maxn], t[maxn], r[maxn], last[maxn]; char ans[maxn]; int main() { int T, m, k; scanf( %d , &T); while (T--) { scanf( %d%d , &m, &k); for (int i = 1; i <= k; i++) { scanf( %d , &num[i]); ... |
#include <bits/stdc++.h> using namespace std; double x; int N, M, ar[5005], res; int dn[5005]; int main() { scanf( %d %d , &N, &M); for (int i = 0; i < N; i++) { scanf( %d %lf , &ar[i], &x); ar[i]--; } for (int i = 0; i < N; i++) { for (int j = ar[i]; j >= 0; j--) { d... |
/**
* Copyright 2020 The SkyWater PDK Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable la... |
`timescale 1ns / 1ps
`include "Defintions.v"
module MiniAlu
(
input wire Clock,
input wire Reset,
output wire [7:0] oLed,
output wire [3:0] oLCD_Data,
output wire oLCD_Enabled,
output wire oLCD_RegisterSelect,
output wire oLCD_ReadWrite,
output wire oLCD_StrataFlashControl
);
//*********... |
#include <bits/stdc++.h> using namespace std; int N, M; int w[401][401]; int last[401], K; double P1[401], P2[401], mxp[402]; int main() { scanf( %d%d , &N, &M); for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) w[i][j] = i == j ? 0 : 1e9; for (int i = 1; i <= M; i++) { int a... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long n, f1, f2, f3, c, ans, t1[3], t2[5], aa1[3][3], aa2[5][5], a1[3][3] = {{0, 0, 1}, {1, 0, 1}, {0, 1, 1}}, a2[5][5] = {{0, 0, 1, 0, 0}, {1, 0, 1, 0, 0}, {0, 1, 1, 0, 0}, ... |
#include <bits/stdc++.h> using namespace std; struct pp { long long nu, we; } c; struct Info { long long l, r, ta, nu; pp a; } a[1000010]; long long b[100010], n, ansn, m, l, r, opt, x, sum; pp mi(pp a, pp b) { if (a.nu < b.nu) return b; return a; } pp ga(long long nu, long long l,... |
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { int n, k, q; cin >> n >> k >> q; vector<long long> vec(n + 1); vector<long long> pq; map<long long, long long> ar, ans, rev; for (int i = 1; i <= n; i++) cin >> vec[i], ar[i] = vec[i], rev[vec[i]] = i; whil... |
#include <bits/stdc++.h> namespace algo { using namespace std; const long double PI = 3.141592653589793238462643383279502884L; const long double E = 2.718281828459045235360287471352662498L; const long double EPS = 1e-12L; template <typename T1, typename T2> T1 bin_pow(T1 a, T2 n) { T1 r = 1; while... |
// Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.
// --------------------------------------------------------------------------------
// Tool Version: Vivado v.2018.2 (win64) Build Thu Jun 14 20:03:12 MDT 2018
// Date : Sun Sep 22 02:34:40 2019
// Host : varun-laptop running 64-bit Service Pac... |
/**
* 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 powerFunction(long long x, long long y) { long long res = 1; long long p = 1000000007; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } bool prime[10000001]; ... |
#include <bits/stdc++.h> using namespace std; int n, a[100002]; int b[100002]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , a + i); int ret = 0; for (int i = n - 1; i >= 0; i--) { int mx = 1; for (int j = 1; j * j <= a[i]; j++) if (a[i] % j == 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; int main() { int n, m, i, j, k, q; scanf( %d%d , &n, &k); n = 1 << n; printf( %d , (n >> (k < n)) - 1), q = i = 0; while (++i < n) if (i < (i ^ k)) printf( %d , i ^ q), q = i; } |
///////////////////////////////////////////////////////////////////////////////
//
// 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; const int N = 1e5 + 5; int T, n, m; int edge, ver; bool mark[N]; int ans[N]; vector<int> G[N], seen, path; void dfs(int v) { ver++; edge += G[v].size(); mark[v] = true; seen.push_back(v); for (int u : G[v]) if (!mark[u]) dfs(u); }... |
#include<stdio.h> #include<iostream> #include<string.h> #include<vector> #include<queue> #include<map> #include<math.h> #include<algorithm> #include<stdlib.h> #include<string> #include<stack> #include<set> using namespace std; #define pb push_back #define POP pop_back() #define DEBUG cout ... |
#include <bits/stdc++.h> using namespace std; int n, k, a[1000005]; long long l; vector<int> val, cou, dp[1000005]; void add(int &a, int b) { a += b; if (a >= 1000000007) a -= 1000000007; } void setup() { cin >> n >> l >> k; for (int i = 0; i <= n - 1; i++) { cin >> a[i]; val.p... |
#include <bits/stdc++.h> using namespace std; int n, k; string a; int change(char c) { int j = 0, i = 0, ans = 0, cont = 0; for (i = 0; i < n; i++) { if (a[i] == c) cont++; if (cont > k) { while (cont > k) if (a[j++] == c) cont--; } ans = max(ans, i - j + 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> using namespace std; using lli = long long; using lld = long double; using ulli = unsigned long long int; using pll = pair<lli, lli>; using ttt = pair<lli, pll>; using vttt = vector<ttt>; using vll = vector<pll>; using vl = vector<lli>; using vi = vector<int>; using vvi = ... |
/*******************************************************************************
* 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 main() { long long m, n, i, t, j; cin >> t; while (t--) { long long one = 0, zro = 0, cnt = 0, ans = 0; cin >> n; vector<long long> v; for (long long j = 0; j < n; j++) { string s; cin >> s; for (long long ... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 10; long long tree[MAXN * 4][7][11], s[6][MAXN], a[MAXN]; void Pushup(long long u, long long len) { long long z, i, j; for (z = 2; z <= 6; z++) for (i = 0; i < 2 * (z - 1); i++) tree[u][z][i] = tree[u * ... |
/**
* 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 = 300000 + 5; const int MOD = 1000000009; int s[N * 4], f[N], a[N], taga[N * 4], tagb[N * 4]; int read() { int x = 0, f = 1; char ch = getchar(); for (; ch < 0 || ch > 9 ; ch = getchar()) if (ch == - ) f = -1; for (; 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... |
module I2C_write_to_memory(
input wire clk,
input wire reset,
input wire run,
input wire [11:0] number_of_bytes,
input wire [14:0] memory_address,
input wire [7:0] data_in,
input wire empty,
input wire ack,
input wire [2:0] memory_number,
output reg read,
output reg [6:0] address,
output reg [7:... |
#include <bits/stdc++.h> int N, K; int use[8]; int per[8]; int level[8]; int A; double res; void dfs(int depth, int st) { int i, j, sum, all, dame; double p, ok, tmp; if (depth == K) { tmp = 0; for (i = 0; i < 1 << N; i++) { p = 1; sum = all = dame = 0; for ... |
#include <bits/stdc++.h> using namespace std; long long calc(int *a, int n) { long long ret = 0, suml = 0; stack<pair<int, int> > st; for (int i = 2; i <= n; i++) { int l = 1; while (!st.empty() && abs(a[i] - a[i - 1]) > st.top().first) { suml -= st.top().first * (long long)st.top().... |
// UC Berkeley CS150
// Lab 3, Fall 2014
// Module: ALU.v
// Desc: 32-bit ALU for the MIPS150 Processor
// Inputs:
// A: 32-bit value
// B: 32-bit value
// ALUop: Selects the ALU's operation
//
// Outputs:
// Out: The chosen function mapped to A and B.
//
// This version written by Arya Reais-Par... |
/*
* Copyright 2018-2022 F4PGA 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in... |
#include <bits/stdc++.h> using namespace std; const unsigned long long MOD = 1e9 + 7; const int INF = 1e9; const unsigned long long INF64 = 9e18; const long double EPS = 1e-9; const long double PI = 3.14159265358979310000; const unsigned long long MD = 535355424; const unsigned long long T = 25342; co... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; string s; cin >> s; for (i = 0; i < s.length(); i++) { if (s[i] == 0 ) break; } if (i == s.length()) cout << s.length(); else cout << i + 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; long long N, Q; long long A[1100100], a, b; vector<pair<long long, long long> > qu[1100100]; long long sol[1100100], dp[1100100]; long long solve(long long I, long long b) { if (I > N) return 0; long long ret = A[I]; return ret += solve(I + b, b); ... |
/******************************************************************************
* License Agreement *
* *
* Copyright (c) 1991-2012 Altera Corporation, San Jose, California, USA. *
... |
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
//
// Revision Control Information
//
// $RCSfile: altera_tse_gxb_gige_inst.v,v $
// $Source: /ipbu/cvs/sio/projects/TriSpeedEthernet/src/RTL/Top_level_modules/... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const long long int INF = (long long int)1e18; const int N = 100005; const long long int MOD = 1000000007; const double EPS = 1e-7; const double PI = acos(-1.0); const int dx[] = {+1, -1, +0, +0}; const int dy[] = {+0, +0, +1, -1}... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int m = 1e9; for (int i = 0; i < n; i++) if (s[i] == R && s[i + 1] == L ) m = min(m, (a[i + 1] - a[i]) / 2); if (m == 1e9) ... |
// 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 : Wed Feb 08 00:47:16 2017
// Host : GILAMONSTER running 64-bit major release (... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.