source_code
stringlengths
26
62k
lang_cluster
stringclasses
11 values
src_uid
stringlengths
32
32
code_uid
stringlengths
32
32
difficulty
int32
-1
3.5k
exec_outcome
stringclasses
1 value
#include <iostream> #include <vector> #include <algorithm> #include <assert.h> using namespace std; #define pb push_back #define ii pair<int, int> #define f1 first #define s2 second const int MAX = 2e5 + 69; int bit[MAX] = {}; vector<ii> history; inline void add(int x, int val) { history.pb({x, val...
C++
6ed24fef3b7f0f0dc040fc5bed535209
e1fb62e2850ef9cb11892f27b4df5226
2,000
PASSED
#include <iostream> #include <vector> #include <algorithm> #include <assert.h> using namespace std; #define pb push_back #define ii pair<int, int> #define f1 first #define s2 second const int MAX = 2e5 + 69; int bit[MAX] = {}; vector<ii> history; inline void add(int x, int val) { history.pb({x, val...
C++
6ed24fef3b7f0f0dc040fc5bed535209
0596236cbe9858673d2a36c64969fe4c
2,000
PASSED
#include <iostream> #include <vector> #include <algorithm> #include <assert.h> using namespace std; #define pb push_back #define ii pair<int, int> #define f1 first #define s2 second const int MAX = 2e5 + 69; int bit[MAX] = {}; vector<ii> history; inline void add(int x, int val) { history.pb({x, val...
C++
6ed24fef3b7f0f0dc040fc5bed535209
dac6897e3a4a24f3b0b33d5921f38817
2,000
PASSED
#include <iostream> #include <vector> #include <algorithm> #include <assert.h> using namespace std; #define pb push_back #define ii pair<int, int> #define f1 first #define s2 second const int MAX = 2e5 + 69; int bit[MAX] = {}; vector<ii> history; inline void add(int x, int val) { // assert(x < MAX)...
C++
6ed24fef3b7f0f0dc040fc5bed535209
41772efd71b71716830eb36f87298a5b
2,000
PASSED
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <set> #include <stdio.h> #include <math.h> #include <iomanip> #include <map> #include <numeric> #define ll long long int using namespace std; int t; int main() { cin >> t; for (int i = 0; i < t; i++) ...
C++
6ed24fef3b7f0f0dc040fc5bed535209
3e8ccd36e48c438c5ccbbcb0134c6363
2,000
PASSED
#include <bits/stdc++.h> using namespace std; #define N 200001 int main() { int t, i = 0; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); vector<int> a(n); for(i = 0; i < n; i++) { scanf("%d", &a[i]); } set<int> s; int f = 1; for(i = 0; i < n && f; i++) { s.insert(...
C++
6ed24fef3b7f0f0dc040fc5bed535209
a65b91649fdc0d94d61bfb247b14f676
2,000
PASSED
#include <bits/stdc++.h> using namespace std; #define N 200001 int main() { ios_base::sync_with_stdio(0), cin.tie(0); int t, i = 0; cin >> t; while(t--) { int n; cin >> n; vector<int> a(n); for(i = 0; i < n; i++) { cin >> a[i]; } set<int> s; int f = 1; for(i = 0; i < n ...
C++
6ed24fef3b7f0f0dc040fc5bed535209
4750b4f832d1e88b7d23cf82c1451fa9
2,000
PASSED
#include <bits/stdc++.h> using namespace std; #define N 200001 int main() { static int a[N]; int t; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d", &a[i]); } set<int> s; int f = 1; for(int i = 0; i < n && f; i++) { s.insert(a...
C++
6ed24fef3b7f0f0dc040fc5bed535209
5fb28398d238dbaa5f9ac864b825302b
2,000
PASSED
#include <bits/stdc++.h> #define int long long using namespace std; const int N=2e3+10; const int mod=1e9+7; int pred[N]; int primes[N]; int tot=0; int lp[N]; string s[N]; void solve() { int n,m; cin>>n>>m; for(int i=0;i<n;i++)cin>>s[i]; int cnt=0; for(int i=0;i<n;i++){ for(...
C++
4e9dfc5e988cebb9a92f0c0b7ec06981
0dfb0114051839ede94dbe23735a01ff
2,300
PASSED
#include<bits/stdc++.h> #include<random> #include<unordered_set> #include<unordered_map> using namespace std; #define bl setiosflags(ios::fixed) << setprecision #define all(x) (x).begin(), (x).end() #define mod 1000000007 #define inf 0x3f3f3f3f #define gg "\n" #define debug(x) cout << #x << ": -----> " << x <...
C++
4e9dfc5e988cebb9a92f0c0b7ec06981
e533ee285b00405413f3c0fc0c4cfddf
2,300
PASSED
#include<bits/stdc++.h> using namespace std; const long long md=1e9+7; int n,m; long long ret=0; char ch; int main() { int T; scanf("%d",&T); while (T--) { bool bo=0; scanf("%d%d",&n,&m); ret=1; for (int i=1;i<=n;i++) { for (int i=1;i<=m;i++) { ch=getchar(); while (ch...
C++
4e9dfc5e988cebb9a92f0c0b7ec06981
b9bb2d114014530f9dd3002c2ceb9544
2,300
PASSED
#include<bits/stdc++.h> using namespace std; const long long md=1e9+7; int n,m; long long ret=0; char ch; int main() { int T; scanf("%d",&T); while (T--) { bool bo=0; scanf("%d%d",&n,&m); ret=1; for (int i=1;i<=n;i++) { for (int i=1;i<=m;i++) { ch=getchar(); while (ch...
C++
4e9dfc5e988cebb9a92f0c0b7ec06981
212bb9ba3e96e07b36b1447d881410e1
2,300
PASSED
// // // ,---, ,----.. ,----....
C++
4e9dfc5e988cebb9a92f0c0b7ec06981
f1233461ee51e34ac946d241d51f66e3
2,300
PASSED
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define Hello_i_am_Salmon ios_base::sync_with_std...
C++
4e9dfc5e988cebb9a92f0c0b7ec06981
9c8c8e00a23eb1cd32d93bec3ad0d54b
2,300
PASSED
#include<bits/stdc++.h> using namespace std; int mod=1e9+7; void tc() { int n,m;cin>>m>>n; int hv0=1,htc=1; for (int i=0;i<n*m;i++) { char s;cin>>s; if (s=='0') hv0=0; else {htc*=2;if (htc>mod) htc-=mod;} } cout<<htc-hv0<<endl; } int main() { int t;cin>>t; ...
C++
4e9dfc5e988cebb9a92f0c0b7ec06981
4fe29a3f3eec4eb84b055d66d5ff7f25
2,300
PASSED
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") using namespace std; using ll = int64_t; constexpr size_t nmax = 1000 + 15; constexpr ll mod = 1000000000 + 7; void do_work(); void do_work() { ll n, m; cin >> n >> m; ll res = 1; ll cnt = 0; for (ll i = 1; ...
C++
4e9dfc5e988cebb9a92f0c0b7ec06981
ba657eb21d49b72b8437817544b0d3e7
2,300
PASSED
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("sse4.2,bmi,bmi2,lzcnt") using ll = long long int; using ull = unsigned long long int; using vi = vector<ll>; using ii = pair<int,int>; using iii = pair<ii,ll>; using vii = vector<ii>; using ld = long doub...
C++
4e9dfc5e988cebb9a92f0c0b7ec06981
7979fb0ef1e2dc62dc4d8f6f138908c2
2,300
PASSED
#include <bits/stdc++.h> using namespace std; #define M 1000000007 int main() { int t; cin >> t; while (t--) { int n, m; cin >> n >> m; int a = 0; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { char c; cin >> c; if (c == '#') a++; } int aa = 1; for (int p = 1...
C++
4e9dfc5e988cebb9a92f0c0b7ec06981
39b8ea4fb0b35461bcf719abce1e1fb3
2,300
PASSED
// everything is predictable expect the death #include<iostream> #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define nd "\n" #define all(x) (x).begin(), (x).end() #define lol cout <<"i am here"<<nd; #define py cout <<"YES"<<nd; #...
C++
7ad1f3f220c12a68c1242a22f4fd7761
eafb76deb35b9c71c8b16577df177fa6
2,600
PASSED
// everything is predictable expect the death #include<iostream> #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define nd "\n" #define all(x) (x).begin(), (x).end() #define lol cout <<"i am here"<<nd; #define py cout <<"YES"<<nd; #...
C++
7ad1f3f220c12a68c1242a22f4fd7761
4214c34453c6bfd4f74f895e4cc6ce68
2,600
PASSED
// everything is predictable expect the death #include<iostream> #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define nd "\n" #define all(x) (x).begin(), (x).end() #define lol cout <<"i am here"<<nd; #define py cout <<"YES"<<nd; #...
C++
7ad1f3f220c12a68c1242a22f4fd7761
0eeb4243cc7aba300f8e5c57e7c94323
2,600
PASSED
#pragma GCC optimaze(3) #pragma GCC optimaze(2) #pragma -Ofast #include<bits/stdc++.h> using namespace std; const long long md=1e9+7; int n; long long ret=0,ans=0; long long a[1000010],b[1000010]; inline long long qsm(long long a,long long b) { long long ret=1; while (b) { if (b&1) ret=ret*a%md; ...
C++
7ad1f3f220c12a68c1242a22f4fd7761
af5ef47ac5b85deedd22a9bb529a9205
2,600
PASSED
#include<bits/stdc++.h> using namespace std; const long long md=1e9+7; int n; long long ret=0,ans=0; long long a[1000010],b[1000010]; inline long long qsm(long long a,long long b) { long long ret=1; while (b) { if (b&1) ret=ret*a%md; b>>=1; a=a*a%md; } return ret; } inline long long C(...
C++
7ad1f3f220c12a68c1242a22f4fd7761
2ca858b3abac133bdd744b3863e06745
2,600
PASSED
#include<bits/stdc++.h> using namespace std; const long long md=1e9+7; int n; long long ret=0,ans=0; long long a[1000010],b[1000010]; inline long long qsm(long long a,long long b) { long long ret=1; while (b) { if (b&1) ret=ret*a%md; b>>=1; a=a*a%md; } return ret; } inline long long C(...
C++
7ad1f3f220c12a68c1242a22f4fd7761
c3357ecf0f7706772fc282e2fc1d9848
2,600
PASSED
#include<bits/stdc++.h> using namespace std; const long long md=1e9+7; int n; long long ret=0,ans=0; long long a[1000010],b[1000010]; inline long long qsm(long long a,long long b) { long long ret=1; while (b) { if (b&1) ret=ret*a%md; b>>=1; a=a*a%md; } return ret; } inline long long C(...
C++
7ad1f3f220c12a68c1242a22f4fd7761
3834e40747ef03f2185614203284c671
2,600
PASSED
#include<bits/stdc++.h> using namespace std; const long long md=1e9+7; int n; long long ret=0,ans=0; long long a[1000010],b[1000010]; inline long long qsm(long long a,long long b) { long long ret=1; while (b) { if (b&1) ret=ret*a%md; b>>=1; a=a*a%md; } return ret; } inline long long C(...
C++
7ad1f3f220c12a68c1242a22f4fd7761
76d037faf23143d24e5348161574c4e2
2,600
PASSED
#include<bits/stdc++.h> using namespace std; const int N=1e6+10,mod=1e9+7; int pw[N],ifac[N],n,ans; int Pow(int x,int t) { int ans=1; while(t) { if(t&1) ans=(1ll)*ans*x%mod; x=(1ll)*x*x%mod;t>>=1; } return ans; } void init(int M=1e6) { pw[0]=ifac[0]=1; for(int i=1;i<=M;i++) pw[i]=(1ll)*pw[i-1]*i...
C++
7ad1f3f220c12a68c1242a22f4fd7761
954a9ff8c917cefd510542aa4bd06bcf
2,600
PASSED
#include<bits/stdc++.h> using namespace std; const int N=1e6+10,mod=1e9+7; int pw[N],ifac[N],n,ans; int Pow(int x,int t) { int ans=1; while(t) { if(t&1) ans=(1ll)*ans*x%mod; x=(1ll)*x*x%mod;t>>=1; } return ans; } void init(int M=1e6) { pw[0]=ifac[0]=1; for(int i=1;i<=M;i++) pw[i]=(1ll)*pw[i-1]*i...
C++
7ad1f3f220c12a68c1242a22f4fd7761
664b663c4e86b5fb8969b37d6f30de1b
2,600
PASSED
/*(لا تَحْزَنْ إِنَّ اللَّهَ مَعَنَا)*/ /*(فصبر جَمِيلٌ عَسَى الله أن يَأْتِيَنِي بِهِمْ جَمِيعًا)*/ /*(إِلَّا تَنْصُرُوهُ فَقَدْ نَصَرَهُ اللَّهُ)*/ #include<bits/stdc++.h> #define Demo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define r_all(v) v.rbegin(),v.rend() #define all(v) v.begin(),v.end() #define ...
C++
55a1e9236cac9a6044e74b1975331535
1e0e7b6d5807dcf729c630b1c26b7eea
1,400
PASSED
#include<bits/stdc++.h> using namespace std; int a[100019],b[100019],c[200019]; int main() { int t=0; cin>>t; while(t--) { int n; cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; for(int i=1;i<=n;i++)cin>>b[i]; for(int i=1,j=1;i<2*n;i+=2) { while(b[j]<i)j++; c[i...
C++
55a1e9236cac9a6044e74b1975331535
142c864b6b055cf411ef939b11194163
1,400
PASSED
#include<iostream> using namespace std; int a[100005],b[100005],cnt[200005]; int main() { int t; cin>>t; while(t--) { int n;cin>>n; for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<=n;i++) scanf("%d",&b[i]); int t=1; for(int i=1;i<=2*n;i+=2) { while(b[t]<i) t++; cnt[i]=t; } int z=1e...
C++
55a1e9236cac9a6044e74b1975331535
688afc999a474ad16f5eb3f1e3308973
1,400
PASSED
#include <bits/stdc++.h> using namespace std; using ll = long long; #define endl '\n' void solve(){ int pos[200005]; int n, temp; cin >> n; for(int i=1 ; i<=n ; i++){ cin >> temp; pos[temp]=i; } for(int i=1 ; i<=n ; i++){ cin >> temp; pos[temp]=i; } int kecil=200005; int ans=200005; for(int i=2*n...
C++
55a1e9236cac9a6044e74b1975331535
92f72ec9da91e36e7526155d94ddbbce
1,400
PASSED
#include <bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; while(t--){ int n; cin >> n; vector<int>Od(n); for(auto &x : Od) cin >> x; vector<pair<int, int>>P; for(int i = 0; i < n; i++){ int x; cin >> x; P.push_back({x, i}); ...
C++
55a1e9236cac9a6044e74b1975331535
48cbbac7abccb207c1855050a1fd6c34
1,400
PASSED
#include <bits/stdc++.h> using namespace std; #define fixed cout << fixed << setprecision(12); #define test int t; cin >> t ; while(t--) #define endl '\n' #define ul unsigned long long #define ld long double #define ll long long #define F first #define S second #define pb push_ba...
C++
55a1e9236cac9a6044e74b1975331535
e4c7514e5780d63814ea86a672e1e774
1,400
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N=1e5+100; int t,n,a[200015]; int main(){ int t; cin>>t; while(t--){ int n; cin>>n; for(int i=1;i<=n;i++){ int x; cin>>x; a[x]=i; } for(int i=1;i<=n;i++){ int x; cin>>x; a[x]=i; } int ds=1e9+7; int sum=1e9+...
C++
55a1e9236cac9a6044e74b1975331535
3c04ecbb8f990503c80160fbe2c4553d
1,400
PASSED
#include <iostream> using namespace std; int main() { int t; cin >> t; while(t--) { int n; cin >> n; long long odd[n], even[n], maximum = 0; for(int i = 0; i < n; i++) cin >> odd[i]; for(int i = 0; i < n; i++) { cin >> even[i]; m...
C++
55a1e9236cac9a6044e74b1975331535
7e820d1b94fbfc33b6d098ede9ae8a79
1,400
PASSED
#include <iostream> using namespace std; const int INF = 1e9; int t, n, a[100005], b[100005], c[200005]; int main() { cin >> t; while (t--) { cin >> n; for (int i = 0; i < 2 * n; i++) { c[i] = INF; } for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } ...
C++
55a1e9236cac9a6044e74b1975331535
2903350c66449f5368e0f8afb78a2bf6
1,400
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int T; cin >> T; int l, r, n, i; while (T--) { l = r = 0x3f3f3f3f; cin >> n; pair<int, int> a[n], b[n]; for (i = 0; i < n; ++i) { cin >> a[i].first; a[i].second = ...
C++
55a1e9236cac9a6044e74b1975331535
0345d951297ee54fa692396d253ee72e
1,400
PASSED
#include<bits/stdc++.h> using namespace std; int a[110]; int main(){ int k; cin>>k; while(k--) { int n; cin>>n; string s; cin>>s; int ans=0; for(int i=0;i<n;i++) { a[i]=s[i]-'0'; } for(int i=0;i<n-1;i++) { ...
C++
6571fdd506a858d7620c2faa0fe46cc1
32a038f1e65f784fce8fe834149f4db0
800
PASSED
#include<bits/stdc++.h> #define ll long long using namespace std; const int N = 1e6+100; #define sz(t) (int)t.size() void solution(){ int n;cin>>n; string s; cin>>s; int ans =0; ans+= s[n-1]-'0'; for(int i =n-2;i>=0;--i){ int val = s[i]-'0'; if(val>0)ans+=val+1; } cout<<ans<<"\n...
C++
6571fdd506a858d7620c2faa0fe46cc1
ddc85853efd5210177c7d54f3423bfe9
800
PASSED
// BELIEVE IN YOURSELF (●'◡'●)❤ // Always Search ◑﹏◐ // ECPC - ACPC - ICPC // programming needs you pationt so don't give up. // Everything good comes after a hard work. // Think twice, Code once!✔ /* "❤--Salma Hatem--❤" */ #include <bits/stdc++.h> #define all(v) v.begin(),v.end() #define TestCases int t; cin >> t;...
C++
6571fdd506a858d7620c2faa0fe46cc1
5243105d9372abd2899dd2c600eb60f1
800
PASSED
#include<iostream> #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; const long double PI = 3.14159265358979323846; const int T = 1e3 + 2; const int TT = 1e4 + 2; const int HT = 2e5 + 2; const int M = 1e6 + 2; const int TM = 1e7 + 2; const int HM = 1e8 + ...
C++
6571fdd506a858d7620c2faa0fe46cc1
37eecace066592277e2832982a974e5e
800
PASSED
//OdyAsh346 A. Countdown #include<bits/stdc++.h> #define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); #define clock cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; #define trav(a,x) for (auto &a : x) #define fori(n) for(int i=0;i<n;++i) #define forj(n) for (int j=0;j<n...
C++
6571fdd506a858d7620c2faa0fe46cc1
35f272f9226f5d2b1bd910673ca43dba
800
PASSED
#include<bits/stdc++.h> using namespace std; #define endl '\n' const int N = 100010; void solved(){ int n; cin>>n; string s; cin>>s; int ans = 0; for(int i=0;i<(int)s.length();i++){ if(i != (int)s.length()-1){ if(s[i] != '0') ans += (s[i]-'0') + 1; } else ans += (s[i] - '0'); } cout<<ans<<endl; } i...
C++
6571fdd506a858d7620c2faa0fe46cc1
9b71ec900e672b5c12f47948d07ce4da
800
PASSED
/**Bismillahir Rahmanir Rahim.**/ /** * author: nasimnoob **/ #include<bits/stdc++.h> using namespace std; //----------------------------------------------------------// typedef long long int ll; typedef unsigned long long int ull; typedef long double ld...
C++
6571fdd506a858d7620c2faa0fe46cc1
cd666ca80f11b44799530356fd21e5be
800
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int #define si(a) scanf("%d", &a) #define sii(a, b) scanf("%d %d", &a, &b) #define siii(a, b, c) scanf("%d %d %d", &a, &b, &c) #define sl(a) scanf("%lld", &a) #define sll(a, b) scanf("%lld %lld", &a, &b) #define slll(a, b, c) scanf("%lld %lld %lld", &a...
C++
6571fdd506a858d7620c2faa0fe46cc1
3928ebf1f1a08a998597d2c07dfd27ec
800
PASSED
#include<bits/stdc++.h> using namespace std; #define endl '\n' typedef long long int ll; typedef pair<int, int> pii; typedef vector<vector<int>> vii; /*****user defined function*****/ void solve_problem() { int n; cin >> n; string str; cin >> str; int ans = 0; int i = 0, j = n-1; while...
C++
6571fdd506a858d7620c2faa0fe46cc1
3d9bb1cf4a9b20d2c5b964aef06706c0
800
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define int ll const int OO = 0x3f3f3f3f3f3f3f3f, mod = 998244353, N = 1e5 + 9; signed main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); #ifdef Clion freopen("input.txt", "r", stdin); freopen("output.txt", "w...
C++
6571fdd506a858d7620c2faa0fe46cc1
857da91402726a6c6157c2e39487db3f
800
PASSED
#include <bits/stdc++.h> #include <ext/numeric> #include <ext/pb_ds/assoc_container.hpp> #define fast cin.tie(0); cin.sync_with_stdio(0); #define ll long long #define ull unsigned long long #define ld long double #define oo (ll)1e9 #define OO (ll)1e18 #define PI acos(-1) #define LL __int128 using namespace s...
C++
af40a0de6d3c0ff7bcd2c1b077b05d6e
9dfb4c479b8b8b5a54e396246707c0a8
1,800
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld double #define f first #define s second const int N = 2e5+5; int n , vis[N] , inS[N] , cy; vector<int> rev[N]; set<int> adj[N]; void dfs(int node) { vis[node] = inS[node] = 1; for(auto ch : adj[node]) { ...
C++
af40a0de6d3c0ff7bcd2c1b077b05d6e
43888bf9a89ff7712128e0fada652afc
1,800
PASSED
#include<bits/stdc++.h> using namespace std; #define endl '\n' #define int long long #define fi first #define se second #define P(x,y) make_pair(x,y) typedef long long ll; const ll INF=1e18; const int N=2e5+15; const int M=2e4; const int mod1=1e9+7; const int mod=998244353; const int base=131; const doubl...
C++
af40a0de6d3c0ff7bcd2c1b077b05d6e
3864583f67da1a13d2ffeac58d7209ef
1,800
PASSED
#include<iostream> #include<queue> #include<vector> using namespace std; static char buf[100000], *pa = buf, *pd = buf; #define gc pa == pd && (pd = (pa = buf) + fread(buf, 1, 100000, stdin), pa == pd) ? EOF: *pa++ inline int read(){ int x(0); char c(gc); while(c < '0' || c > '9'){ c = gc;...
C++
af40a0de6d3c0ff7bcd2c1b077b05d6e
6ebbc71978bcff01102f0dfa5b4aafc2
1,800
PASSED
#include<iostream> #include<queue> #include<vector> using namespace std; static char buf[100000], *pa = buf, *pd = buf; #define gc pa == pd && (pd = (pa = buf) + fread(buf, 1, 100000, stdin), pa == pd) ? EOF: *pa++ inline int read(){ int x(0); char c(gc); while(c < '0' || c > '9'){ c = gc;...
C++
af40a0de6d3c0ff7bcd2c1b077b05d6e
b9c23ec98ecfc59e1a03f9655d6953a1
1,800
PASSED
#include<bits/stdc++.h> using namespace std; int main(){ int tt;cin>>tt; while(tt--){ int n;cin>>n; queue<int>q; vector<vector<int>>a(n); vector<int>ans(n),val(n); for(int i=0;i<n;++i){ int m;cin>>m; if(m==0){ q.push(i); ans[i]=1; } while(m--){ int v;cin>>v; a...
C++
af40a0de6d3c0ff7bcd2c1b077b05d6e
8e899e9097c78c5457b4272065fff893
1,800
PASSED
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <bitset> #include <array> #include <ioma...
C++
af40a0de6d3c0ff7bcd2c1b077b05d6e
1dd5c0103061e2d38916632b5309006c
1,800
PASSED
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <bitset> #include <array> #include <ioma...
C++
af40a0de6d3c0ff7bcd2c1b077b05d6e
b8d4c92cd91f1caccc7fa4a482bb9966
1,800
PASSED
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <bitset> #include <array> #include <ioma...
C++
af40a0de6d3c0ff7bcd2c1b077b05d6e
976e7f3fe4097b70c72e11f9451cbacd
1,800
PASSED
#include<bits/stdc++.h> using namespace std; const int N = 3e5; bool st[N]; vector<int>e[N]; int ans ; vector<int>path; int cnt; int num; int a[N]; int din[N]; int dp[N];int n; bool topsort() { queue<int>q; int sum = 0; for(int i = 1;i <= n;i++) { if(!din[i]) {q.push(i); sum++;} } while(!q.empty()) { i...
C++
af40a0de6d3c0ff7bcd2c1b077b05d6e
60b184c6de15ff027790a01c41292b4b
1,800
PASSED
#include <bits/stdc++.h> #define enter putchar('\n') #define debug(x) cerr<<#x<<" = "<<x<<endl #define mp make_pair #define pb push_back #define fx first #define fy second using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> Poly; typedef double db; const int mod = 9...
C++
fb0315300b981f91d69d6ea164e674b4
5da33691942f8dd630e3fec6f64248e8
2,700
PASSED
#include <bits/stdc++.h> #define enter putchar('\n') #define debug(x) cerr<<#x<<" = "<<x<<endl #define mp make_pair #define pb push_back #define fx first #define fy second using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> Poly; typedef double db; const int mod = 9...
C++
fb0315300b981f91d69d6ea164e674b4
560911ffd383cf64db6967d4a94c6482
2,700
PASSED
#include <bits/stdc++.h> #define enter putchar('\n') #define debug(x) cerr<<#x<<" = "<<x<<endl #define mp make_pair #define pb push_back #define fx first #define fy second using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> Poly; typedef double db; const int mod = 9...
C++
fb0315300b981f91d69d6ea164e674b4
cc148c18288e81a5244e5fe47173a569
2,700
PASSED
#include <bits/stdc++.h> using namespace std; const int NN = 5020; int a[NN], b[NN]; vector<int> vec[NN]; int dp[NN][NN]; void solve() { int n; cin >> n; for(int i = 1; i <= n; i ++) cin >> a[i]; int m = 0; for(int i = 1; i <= n; i ++) if(b[m] != a[i]) b[ ++m] = a[i]; for(int i = 1; i <= m; i ++) vec[b[i]].pus...
C++
fb0315300b981f91d69d6ea164e674b4
814945d767cbb77286f64ab261b16395
2,700
PASSED
#include<cstdio> #include<cstring> #include<cctype> #include<cstdlib> #include<cmath> #include<iostream> #include<sstream> #include<iterator> #include<algorithm> #include<string> #include<vector> #include<set> #include<map> #include<deque> #include<queue> #include<stack> #include<list> #define ll long ...
C++
fb0315300b981f91d69d6ea164e674b4
d4463637a1fa0ec79f85f5539ffdf215
2,700
PASSED
#include<cstdio> #include<cstring> #include<cctype> #include<cstdlib> #include<cmath> #include<iostream> #include<sstream> #include<iterator> #include<algorithm> #include<string> #include<vector> #include<set> #include<map> #include<deque> #include<queue> #include<stack> #include<list> #define ll long ...
C++
fb0315300b981f91d69d6ea164e674b4
1981b7f3263fb3fbcb035c63a3bedaf6
2,700
PASSED
#include <bits/stdc++.h> using namespace std; const int MAX = 3e3; int test, n, a[MAX + 1], f[MAX + 1][MAX + 1], pre[MAX + 1], idx[MAX + 1]; int main() { // freopen("in.txt", "r", stdin); scanf("%d", &test); while (test--) { scanf("%d", &n); for (int i = 1; i <= n; ++i) { ...
C++
fb0315300b981f91d69d6ea164e674b4
13779782a90aeb30a0a55fbfb36db063
2,700
PASSED
#include <bits/stdc++.h> using namespace std; const int MAX = 3e3; int test, n, a[MAX + 1], f[MAX + 1][MAX + 1], pre[MAX + 1], idx[MAX + 1]; int main() { // freopen("in.txt", "r", stdin); scanf("%d", &test); while (test--) { scanf("%d", &n); for (int i = 1; i <= n; ++i) { ...
C++
fb0315300b981f91d69d6ea164e674b4
df4a703528e2b6ecf2e903588753674e
2,700
PASSED
#include<bits/stdc++.h> using namespace std; const int N=5005; const int inf=1e9; int T; int p[N]; int q[N]; int a[N]; int dp[N][N]; signed main(){ ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); cin>>T; while(T--){ int n; cin>>n; for(int i=1;i<=n+1;i++) p[i]=n+1; for(int i=1;i<=n;i++)...
C++
fb0315300b981f91d69d6ea164e674b4
09b35a8a3c9c3bbf4ca86c1a43479a3a
2,700
PASSED
#include <bits/stdc++.h> using namespace std; #define maxn 3010 vector<int> colorseq[maxn]; int dp[maxn][maxn]; int a[maxn]; int redirecti[maxn]; int main() { int t, n, c; cin >> t; while (t--) { cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; colorseq[a[i]].push_bac...
C++
fb0315300b981f91d69d6ea164e674b4
932fe8de67a0b3323a49758b3f267bbb
2,700
PASSED
#include <iostream> #include <vector> #include <cmath> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") using namespace std; void solve() { vector<int> ans; vector<int> v; int n; cin >> n; v.resize(n); int sum = 0; for (int i = 0; i < n; i++) { cin >...
C++
1f714ac601f6b5bdcb4fa32cdb56629d
5e0f6ddd13c9e342715df7b0694297f4
2,500
PASSED
#include <bits/stdc++.h> #define ll long long #define fastio ios::sync_with_stdio(false);cin.tie(NULL) using namespace std; const int INF=1e9+10; // (2,0),(4,3),..() void solve(){ int n;cin>>n; vector<int>a(n+1); int curidx=0,cnt=0; for (int i=0;i<n;++i){ int k; cin>>k; if (k==0) curidx=i+1; ...
C++
1f714ac601f6b5bdcb4fa32cdb56629d
7a0ab4c3f8bd4899ff267eb14c0ef85f
2,500
PASSED
#include <array> #include <algorithm> #include <array> #include <cassert> #include <cinttypes> #include <cstdint> #include <cstdio> #include <fstream> #include <optional> #include <iostream> #include <map> #include <set> #include <string> #include <tuple> #include <vector> #ifdef ONLINE_JUDGE std::ist...
C++
1f714ac601f6b5bdcb4fa32cdb56629d
2115c1d76e514e02ed1373936c9e8150
2,500
PASSED
#include <array> #include <algorithm> #include <array> #include <cassert> #include <cinttypes> #include <cstdint> #include <cstdio> #include <fstream> #include <optional> #include <iostream> #include <map> #include <set> #include <string> #include <tuple> #include <vector> // IO functions template <ty...
C++
1f714ac601f6b5bdcb4fa32cdb56629d
ddc880288a37c675a35e1391cf217799
2,500
PASSED
#include <array> #include <algorithm> #include <array> #include <cassert> #include <cinttypes> #include <cstdint> #include <cstdio> #include <fstream> #include <optional> #include <iostream> #include <map> #include <set> #include <string> #include <tuple> #include <vector> // IO functions template <ty...
C++
1f714ac601f6b5bdcb4fa32cdb56629d
8d008f542f7926c71ac59b848b58399f
2,500
PASSED
#include <array> #include <algorithm> #include <array> #include <cassert> #include <cinttypes> #include <cstdint> #include <cstdio> #include <fstream> #include <optional> #include <iostream> #include <map> #include <set> #include <string> #include <tuple> #include <vector> // IO functions template <ty...
C++
1f714ac601f6b5bdcb4fa32cdb56629d
7c43a89bbc4634b7e0afdd659e642398
2,500
PASSED
#include <array> #include <algorithm> #include <array> #include <cassert> #include <cinttypes> #include <cstdint> #include <cstdio> #include <fstream> #include <optional> #include <iostream> #include <map> #include <set> #include <string> #include <tuple> #include <vector> // IO functions template <ty...
C++
1f714ac601f6b5bdcb4fa32cdb56629d
4557389c4467fbe0bf7308513aac9ea8
2,500
PASSED
#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include<bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int x, int y) {return (rng() % (y-x +1)) + x;}; #define ll long long #define pb push_back ...
C++
1f714ac601f6b5bdcb4fa32cdb56629d
cfd8780058d4ce1d7060c18a0a21747f
2,500
PASSED
#include <bits/stdc++.h> using namespace std; #define all(x) begin(x), end(x) #define size(x) int((x).size()) using ll = long long; int solve() { int n; cin >> n; vector a(n, 0); for (int& i : a) cin >> i; if (count(all(a), 1) & 1) { return cout << "NO\n", 0; } vector b(1, pair(0, n - 1...
C++
1f714ac601f6b5bdcb4fa32cdb56629d
383b91f51edee5c3abf95cf46065c595
2,500
PASSED
#include<bits/stdc++.h> using namespace std; int n , a [200005]; vector < int > ans; void ks ( int i ) { for ( int j = i ; j <= n - 2 ; j += 2 ) { if ( a [ j + 1 ] == 0 ) return; a [j] = 0 , a [ j + 1 ] = 0 , a [ j + 2 ] = 0; ans . push_back ( j ); } } void amk ( int i )...
C++
1f714ac601f6b5bdcb4fa32cdb56629d
d2ff9091812ce825e5505a7bfc71d1a5
2,500
PASSED
#include <bits/stdc++.h> using namespace std; namespace IO { const int MT = 10 * 1024 * 1024; // modify size char IO_BUF[MT]; int IO_PTR, IO_SZ; // init void begin() { IO_PTR = 0; IO_SZ = fread(IO_BUF, 1, MT, stdin); } template <typename T> inline bool scan_d(T &t) { while (IO_PTR < IO_SZ && IO_BUF[IO_PTR] !...
C++
abbe1822842cfe959d7c61cc5e364edf
71e20947f78689691a2d5f12da99953f
2,800
PASSED
#include <bits/stdc++.h> using namespace std; template <class Flow, class Cost> struct Primal_Dual { // based on EK struct edge { int u, v; Flow f; Cost c; edge(int _u, int _v, Flow _f, Cost _c) : u(_u), v(_v), f(_f), c(_c){}; }; int n; Cost inf_cost; Flow inf_flow; vector<vector...
C++
abbe1822842cfe959d7c61cc5e364edf
c5eaa9b16d51ad5757a05ac07b0b5975
2,800
PASSED
//cv rainboy 的 //总之是个优化边数的垃圾图匹配,不想写辣! #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #define N 20 #define K 200 #define M (K * N * 2) #define N_ (M * 2) #define A 2000000 unsigned int X; void srand_() { struct timeval tv; gettimeofday(&tv, NULL); ...
C++
abbe1822842cfe959d7c61cc5e364edf
be58afb809dc2f8d785bf0d32aed25d6
2,800
PASSED
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #define N 20 #define K 200 #define M (K * N * 2) #define N_ (M * 2) #define A 2000000 unsigned int X; void srand_() { struct timeval tv; gettimeofday(&tv, NULL); X = tv.tv_sec ^ tv.tv_usec | 1; } int rand_() { ...
C++
abbe1822842cfe959d7c61cc5e364edf
5e2e773907357142069d01e03d12535c
2,800
PASSED
#include<bits/stdc++.h> #define ll long long #define L(i, j, k) for(int i = (j); i <= (k); ++i) #define R(i, j, k) for(int i = (j); i >= (k); --i) #define vi vector < int > #define sz(a) ((int) a.size()) using namespace std; const int N = 21, inf = 1e7; int n, k, a[1 << N], pre[1 << N], ns, cs[1 << N]; inline ...
C++
abbe1822842cfe959d7c61cc5e364edf
5a7aff6d139c881090979ba399273ee3
2,800
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define pll pair<long long,long long> struct FlowEdge { int u, v; long long cap, cost, flow = 0; FlowEdge(int u, int v, long long cap, long long cost) : u(u), v(v), cap(cap), cost(cost) {} }; struct MinC...
C++
abbe1822842cfe959d7c61cc5e364edf
bccd743dbed4dacdb990709f1f6c2f3a
2,800
PASSED
#include <bits/stdc++.h> #define ll long long using namespace std; struct Edge { int from, to, capacity, cost; }; vector<vector<int>> adj; vector<map<int, int>> cost, capacity; const int INF = 1e9; void shortest_paths(int n, int v0, vector<int>& d, vector<int>& p) { d.assign(n, INF); d[v0] = 0; vector<bool>...
C++
abbe1822842cfe959d7c61cc5e364edf
928e5afce0bebc83aaf2eb76054aab74
2,800
PASSED
/* K.D. Vinit /,,/ */ #include<bits/stdc++.h> using namespace std; //#define int long #define endl "\n" //Works for both directed, undirected and with negative cost too //doesn't work for negative cycles //for undirected edges just make the directed flag false //Complexity: O(min(E^2 *V log V, E logV * f...
C++
abbe1822842cfe959d7c61cc5e364edf
972368a75e9cae14dc4d30ba603ae21e
2,800
PASSED
/* K.D. Vinit /,,/ */ #include<bits/stdc++.h> using namespace std; #define int long #define endl "\n" //Works for both directed, undirected and with negative cost too //doesn't work for negative cycles //for undirected edges just make the directed flag false //Complexity: O(min(E^2 *V log V, E logV * flo...
C++
abbe1822842cfe959d7c61cc5e364edf
516b57c66163db7663c14918f50f1e40
2,800
PASSED
/* K.D. Vinit /,,/ */ #include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" //Works for both directed, undirected and with negative cost too //doesn't work for negative cycles //for undirected edges just make the directed flag false //Complexity: O(min(E^2 *V log V, E logV ...
C++
abbe1822842cfe959d7c61cc5e364edf
9804ca6a41ee031067911b95adbec8d2
2,800
PASSED
#include <algorithm> #include <assert.h> #include <iostream> #include <iomanip> #include <cstdio> #include <cstring> #include <vector> #include <set> #include <unordered_set> #include <utility> #include <limits.h> #include <climits> #include <numeric> #include <map> #include <unordered_map> #include <cfloat> #define ll...
C++
1759fabd248d2b313ecfb8e1b3e7b0db
515f9216468959a5fa8a6b0fff8f02e1
2,500
PASSED
// LUOGU_RID: 94288158 #include <bits/stdc++.h> #define int long long using namespace std; const int M = 1e9 + 7; const int N = 1e6 + 5; int tot[N]; inline int read(){ int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();} while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=get...
C++
1759fabd248d2b313ecfb8e1b3e7b0db
2411e1b1d4921aa4093e272604938345
2,500
PASSED
#include <bits/stdc++.h> #define int long long using namespace std; const int M = 1e9 + 7; const int N = 1e6 + 5; int tot[N]; inline int read(){ int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();} while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar(); return s*w;...
C++
1759fabd248d2b313ecfb8e1b3e7b0db
39530891865e3add14e7fadbd1f633cf
2,500
PASSED
#include <bits/stdc++.h> #define int long long using namespace std; const int M = 1e9 + 7; const int N = 1e6 + 5; int tot[N]; inline int read(){ int s=0,w=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();} while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar(); return s*w;...
C++
1759fabd248d2b313ecfb8e1b3e7b0db
61dbfe476710e00c9978d3c9892e55d3
2,500
PASSED
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1e9+7; const int INF = 1e9; const ll INFLL = 1e18; ll binPow(ll base, ll exp) { ll ans = 1; while(exp) { if(exp%2) { ans = (ans*base)%MOD; } exp >>= 1; base = (base*base)%MOD; } return ans; }...
C++
1759fabd248d2b313ecfb8e1b3e7b0db
844eb6ac951d778599247001dfb5a464
2,500
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long #define yu (1000000007) inline ll ksm(ll x,ll y) { ll an=1; for(;y;y>>=1) { if(y&1) { an*=x; an%=yu; } x*=x; x%=yu; } return an; } #define N 1000010 ll n; ll f[N]; ll ans[N],sum[N],ji[N]; int main() { //freo...
C++
1759fabd248d2b313ecfb8e1b3e7b0db
2c6e342391c9f2b8ddf775827a8f0f2b
2,500
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long #define yu (1000000007) inline ll ksm(ll x,ll y) { ll an=1; for(;y;y>>=1) { if(y&1) { an*=x; an%=yu; } x*=x; x%=yu; } return an; } #define N 1000010 ll n; ll f[N]; ll ans[N],sum[N],ji[N]; int main() { //freo...
C++
1759fabd248d2b313ecfb8e1b3e7b0db
4fbd9923ba658b04480f1d6fc04aa36e
2,500
PASSED
#include<bits/stdc++.h> using namespace std; const int N = 2e6+10, mod = 1e9+7; int dp[N], ff[N], suf[N], pow2[N]; int n, m, T; inline int quickpow(int x, int b, int mod){ int j = 1; for(; b; b >>= 1, x = 1ll * x * x % mod) if(b & 1) j = 1ll * j * x % mod; return j % mod; } int main(){ ...
C++
1759fabd248d2b313ecfb8e1b3e7b0db
d45a28336a7eb5833aebc2235aae5783
2,500
PASSED
#include <cstdio> #include <algorithm> using namespace std; typedef long long ll; const int mod = 1e9 + 7, N = 1000010; int T,n; template <typename T> inline void read(T &x){ x = 0; char ch = getchar(); int f = 1; for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1; for(;ch >= '0' &&...
C++
1759fabd248d2b313ecfb8e1b3e7b0db
edda4ec1cb1aa6ad3dbe416cae83d72a
2,500
PASSED
// LUOGU_RID: 90273257 #include <bits/stdc++.h> #define rep(i,l,r) for (int i = l; i <= r; i++) #define per(i,r,l) for (int i = r; i >= l; i--) #define fi first #define se second #define prt std::cout #define gin std::cin #define edl std::endl namespace wxy{ const int N = 1e6 + 50,mod = 1e9 + 7; int n...
C++
1759fabd248d2b313ecfb8e1b3e7b0db
c29e7d9ff150bdf6876673a9fd22b1f1
2,500
PASSED
#include<bits/stdc++.h> #define int ll #define pb push_back #define mp make_pair #define pii pair<int,int> #define fir first #define sec second using namespace std; typedef long long ll; const int N=505; const int inf=1000000005; const ll inff=1ll<<60; const int mod=1000000007; inline int read(){ int x=0,f=1;char c=ge...
C++
e27ffab64e694b9d612fe100f4c503b8
61ab1c3742a12b8832e6109922290134
2,200
PASSED
#include<bits/stdc++.h> #define int ll #define pb push_back #define mp make_pair #define pii pair<int,int> #define fir first #define sec second using namespace std; typedef long long ll; const int N=505; const int inf=1000000005; const ll inff=1ll<<60; const int mod=1000000007; inline int read(){ int x=0...
C++
e27ffab64e694b9d612fe100f4c503b8
75be1373d54a55f64fc30052eb8a9346
2,200
PASSED