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<bits/stdc++.h>
using namespace std;
const int N=100005,p=1e9+7;
int a[N],b[505],f[N];
int ans=0,n,tot=0;
int main(){
scanf("%d",&n);f[0]=1;
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n;i++){
memset(b,0,sizeof(b));tot=0;
for(int j=1;j*j<=a[i]&&j<=i;j++){
if(a[i]%j==0){
b[++tot]=j;
... | C++ | 587ac3b470aaacaa024a0c6dde134b7c | 27b86d523cb8c391b3484e3d79d76e38 | 1,700 | PASSED |
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
//fengxunling
#define mod 1000000007
#define MAXN 100010
using namespace std;
int n;
int a[MAXN];
long long dp[MAXN],ans;
vector<int>v[MAXN];
inline void getsum(int id,int now)
{
int x=now;
for(int i=1;i*i<=x;i+... | C++ | 587ac3b470aaacaa024a0c6dde134b7c | ebe043dea46a2e6b0faf421bf4a83107 | 1,700 | PASSED |
#include <bits/stdc++.h>
#define show(a) cout << #a << " = " << a << endl;
#define endl "\n"
const int MOD = 1e9+7;
const int MAXN = 1e6+5;
const int INF = 500005;
typedef long long ll;
using namespace std;
ll dp[MAXN] {};
int main()
{
std::ios::sync_with_stdio(false);
int n;
cin >> n;
ll a[n+5];... | C++ | 587ac3b470aaacaa024a0c6dde134b7c | b16150248ad7bb3329dc7e8315d2719d | 1,700 | PASSED |
#include <bits/stdc++.h>
#define show(a) cout << #a << " = " << a << endl;
#define endl "\n"
const int MOD = 1e9+7;
const int MAXN = 1e6+5;
const int INF = 500005;
typedef long long ll;
using namespace std;
ll dp[MAXN] {};
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n;
... | C++ | 587ac3b470aaacaa024a0c6dde134b7c | 88661a962efea1aff3da7866a3fb92d7 | 1,700 | PASSED |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long MOD = 1000000007;
long long dp[100005], ans;
int v[100005];
vector <int> divs[100005];
void FindDivs(int ind)
{
for(int i = 1; i * i <= v[ind]; i++)
if(v[ind] % i == 0)
{
divs[ind].push_ba... | C++ | 587ac3b470aaacaa024a0c6dde134b7c | d339ec41823f57d979ea7951771de8fe | 1,700 | PASSED |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> ii;
///////////////////////////////////////////////////////// BEGIN OF SIEVE /////////////////////////////////////////////////////////
//TODO: divisores em O(d) - recursivo
class FactorSieve {... | C++ | 587ac3b470aaacaa024a0c6dde134b7c | d616035e667c738d692eca7a9ea991e0 | 1,700 | PASSED |
#include<bits/stdc++.h>
using namespace std;
int n , a[100000] , Add , ans ;
int main()
{
cin >> n ;
for (int i = 0 ; i<n ; i++)
{
cin >> a[i] ;
}
for (int i = 0 ; i<n; i++)
{
if(a[i] == i)ans++;
else if ( a[a[i]] == i ){Add = 2 ;}
else Add = max (Add , 1 ) ;
}
... | C++ | e63de0fffd00b2da103545a7f1e405be | eddff2fa27384bdbf80ccc330b02be4e | 1,100 | PASSED |
//
// main.cpp
// B
//
// Created by timothyliu on 2017/11/29.
// Copyright © 2017年 timothyliu. All rights reserved.
//
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int a[100000];
int main(int argc, const char * argv[]) {
int n,point=0;
int d=0;
cin>>n;
for(int i... | C++ | e63de0fffd00b2da103545a7f1e405be | 6af9af8a052ae08353bc882ecb20c945 | 1,100 | PASSED |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,v=0,t=0;
cin >> n;
int a[n];
for(int i=0;i<n;i++)
cin >> a[i];
for(int i=0;i<n;i++){
if(a[i]==i)
v++;
else if(a[a[i]]==i)
t++;
}
if(v==n)
cout << v;
else if(t>=1)
... | C++ | e63de0fffd00b2da103545a7f1e405be | 704ddc059bbe22be832dd78db532c664 | 1,100 | PASSED |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ll n;
ll i;
cin >> n;
l... | C++ | e63de0fffd00b2da103545a7f1e405be | a9bec29a34cbe78fd8a8f45cd412be93 | 1,100 | PASSED |
#include <iostream>
using namespace std;
int a[100001];
int main()
{
int n;
cin >> n;
int ans = 0;
bool kt = false;
for (int i = 0; i < n; ++i) {
cin >> a[i];
if (a[i] == i)
ans++;
}
if (ans == n)
{
cout << ans;
return 0;
}
if (ans == n - 2)
{
cout << ans + 2;
return ... | C++ | e63de0fffd00b2da103545a7f1e405be | c7cb63981569a2975e125edab9e3089f | 1,100 | PASSED |
#include<bits/stdc++.h>
using namespace std;
int i,a[1000000],x,c,a1,n;
int main()
{
cin>>n;
for(int i=0;i<n;i++) cin>>a[i];
for(int j=0;j<n;j++)
{
if (a[j]==j) c++;
else if(a[a[j]]==j) a1++;
}
cout<<min(n,c+!!a1+1... | C++ | e63de0fffd00b2da103545a7f1e405be | f603fd31d68e3482cb8a178f9c7f0915 | 1,100 | PASSED |
/*
*Author - Bhanu Pratap
*/
#include <bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define rep(i,a,b) for (int i=a; i<b; i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9 + 7;
const ld PI = 3.141592653589793;
co... | C++ | e63de0fffd00b2da103545a7f1e405be | 7c096a566bd1886304dceeee525b6d3c | 1,100 | PASSED |
#include<cstdio>
#include<iostream>
using namespace std;
int n,a[100000+100],sol,sol1;
bool o[100000+100];
int main()
{
cin>>n;
for (int i=1;i<=n;i++)
{
int x;
scanf("%d",&x);
a[x]=i-1;
}
for (int i=0;i<n;i++)
{
if (o[i])continue;
if (a[i]==i)sol++,o[i]=true;
else
... | C++ | e63de0fffd00b2da103545a7f1e405be | f07fdfbe004b5f88bea6765394858baa | 1,100 | PASSED |
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<utility>
#include<map>
#include<vector>
#include<cstring>
using namespace std;
int n,mapa[1000000+100],sol,br;
int main()
{
cin>>n;
for (int i=0;i<n;i++)
{
int x;
scanf("%d",&x);
mapa[x]=... | C++ | e63de0fffd00b2da103545a7f1e405be | 4dd0836386eae82d80072a4efe7bf4cf | 1,100 | PASSED |
#include<bits/stdc++.h>
using namespace std;
int aa[100005];
int dp[100005];
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&aa[i]);
dp[aa[i]]=i;
}
int ans=0;
int work=1;
for(int i=0;i<n;i++)
{
if(aa[i]==i)
ans++;
els... | C++ | e63de0fffd00b2da103545a7f1e405be | a748e5314eecb90d8a98ce102bd9e6dc | 1,100 | PASSED |
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace ... | C++ | 7b44d8a815c0b9702ce15f3353875468 | 391193c84d41ef187d9b33b60a96336f | 1,600 | PASSED |
#include <stdio.h>
#include <vector>
#include <iostream>
#include <map>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <queue>
#include <math.h>
#include <set>
#pragma comment(linker, "/stack:64000000")
const int INF = 1000 * 1000 * 1000;
using namespace std;
typedef long long int i64;
const int... | C++ | 7b44d8a815c0b9702ce15f3353875468 | ca6402c98a202d836269319d402d3391 | 1,600 | PASSED |
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <sstream>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#i... | C++ | 7b44d8a815c0b9702ce15f3353875468 | d0d8a91c1c02920c81ee223a5f89d410 | 1,600 | PASSED |
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <ite... | C++ | 7b44d8a815c0b9702ce15f3353875468 | 87b07f0b3065de3cdc2d1b0090874b06 | 1,600 | PASSED |
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <functional>
using namespace std;
#pragma comment(linker,"/STACK:100000000")
int ans[(1 << 20) + 5];
set <int> S, T;
int main()
... | C++ | 7b44d8a815c0b9702ce15f3353875468 | 7dbbc5fc2cca5a037e345cb1ac3e9373 | 1,600 | PASSED |
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long lon... | C++ | 7b44d8a815c0b9702ce15f3353875468 | 05818e3be349ec72fbd9e59de67d8d55 | 1,600 | PASSED |
#pragma warning(disable:4786)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<cstd... | C++ | 7b44d8a815c0b9702ce15f3353875468 | d3ecf25732f59a71917e667445fd64d8 | 1,600 | PASSED |
#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <bitset>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#in... | C++ | 7b44d8a815c0b9702ce15f3353875468 | 89b02420314f78efaf3bb61710408dc2 | 1,600 | PASSED |
#include<iostream>
#include<set>;
using namespace std;
int main()
{
int n, a, temp = 0;
cin>>n;
set<int> ans, set1, set2;
for(int i=0; i<n; i++)
{
cin>>a;
set1.clear();
set1.insert(a);
ans.insert(a);
for(set<int>::iterator it = set2.begin(); it!=set2.end(); i... | C++ | 7b44d8a815c0b9702ce15f3353875468 | 42790afc5122cfa47cabe37dec72420a | 1,600 | PASSED |
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <exception>
#include <numeric>
using namespace std;
typedef vector< vector<long long> > vvl;
typedef vector< long long> vl;
typedef pair<long, long > ll;... | C++ | 7b44d8a815c0b9702ce15f3353875468 | b2d05e35e55aa36e106853f33a5f873f | 1,600 | PASSED |
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <map>
#include <assert.h>
#define SI(i) scanf("%d", &i)
#define SII(i,j) scanf("%d%d", &i, &j)
#define SIII(i,j,k) scanf("%d%d%d", &i, &j, &k)
#define SS(i) sca... | C++ | 71bc7c4eb577441f2563e40d95306752 | 5b45c5676c25f14aa15aa6baeccb8009 | 1,400 | PASSED |
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cst... | C++ | 71bc7c4eb577441f2563e40d95306752 | d3b062e84472e22a7c41e6caf737e333 | 1,400 | PASSED |
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cs... | C++ | 71bc7c4eb577441f2563e40d95306752 | 68826054584a73b411af4343b00da9e3 | 1,400 | PASSED |
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
using namespace std;
int R[100005]={};
int L[100005]={};
int main(){
int n;cin>>n;
for(int i=0;i<n;i++)
cin>>L[i]>>R[i];
for(i... | C++ | 71bc7c4eb577441f2563e40d95306752 | e1b654b7c23977e6d82b6695a4930377 | 1,400 | PASSED |
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
int n,k=0;
cin >> n;
int** array = new int*[n];
for (int i = 0; i < n; i++)
{
array[i] = new int [2];
cin >> array[i][0] >> array[i][1];
}
for (int i = n - 1; i > 0; i--) {
for (int j = 0; j < i; j++) {
if (arra... | C++ | 71bc7c4eb577441f2563e40d95306752 | adc49edb05873399113b1a77136e4194 | 1,400 | PASSED |
#include <iostream>
#include <algorithm>
using namespace std;
struct date{
int a,b;
}d[5001];
bool cmp(date a,date b){
if(a.a<b.a)
return 1;
else if(a.a==b.a){
if(a.b<b.b)
return 1;
else
return 0;
}
else if(a.a>b.a)
return 0;
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++)
cin>>d[i].a>>d[i].b... | C++ | 71bc7c4eb577441f2563e40d95306752 | 1089aed3fe2aa815a42d32ea01f4d4f3 | 1,400 | PASSED |
#include <iostream>
#include <algorithm>
#define forn(i, n) for(int i = 0; i < (int) n; i ++)
#define ln long long
using namespace std;
pair <ln, ln> a [5010];
int main()
{
int n;
cin >> n;
forn(i, n)
{
cin >> a[i].first;
cin >> a[i].second;
}
sort(a, a + n);
int good = -1;
forn(i, n)
if (good <= a[i]... | C++ | 71bc7c4eb577441f2563e40d95306752 | 07051fec9cb052e9d3c176273f139f53 | 1,400 | PASSED |
#include <stdio.h>
struct STUD {
int formal;
int fact;
} mass[5001];
void reStruct(STUD*, int, int);
void swap(STUD*, STUD*);
int main(void) {
int n;
scanf_s("%d", &n);
for (int i = 0; i < n; i++)
scanf_s("%d %d", &mass[i].formal, &mass[i].fact);
for (int i = (n - 1) / 2; i > -1; i-... | C++ | 71bc7c4eb577441f2563e40d95306752 | be033d207a289c7df758dea36fee02cf | 1,400 | PASSED |
#include <cstdio>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;
pair <int, int> a[5000];
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i].first >> a[i].second;
sort(a, a + n);
int currentday = 0;
for (int i = 0; i < n; i++)
{
if (currentda... | C++ | 71bc7c4eb577441f2563e40d95306752 | c8886abbe33dd3f2b4d57d0c55458e7c | 1,400 | PASSED |
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
void main()
{
int n,a=0; cin>>n;
vector<pair<int,int> >v(n);
for(int i=0; i<n; ++i)
cin>>v[i].first>>v[i].second;
sort(v.begin(),v.end());
for(int i=0; i<n; ++i)
{
if(v[i].second>=a)a=v[i].second;
else a=v[i].firs... | C++ | 71bc7c4eb577441f2563e40d95306752 | d5ca004b51bf38c031458a37d3a8b178 | 1,400 | PASSED |
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repr(i, a, b) for (ll i = a; i < b; i++)
#define all(a) a.begin(), a.end()
#define w(tc) \
ll tc; \
cin >> tc; \
while (tc--)
#define fastio \
ios_base::sync_with_stdio(false); ... | C++ | 0f7ceecdffe11f45d0c1d618ef3c6469 | 182a2afb60f4a0db0990d6cc49adc0d7 | 1,300 | PASSED |
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int N = 1e7+10;
int prime[N],cnt;
bool p[N] = {false};
void init(int n){
for(int i=2;i<=n;++i){
if(p[i] == false)
prime[++cnt] = i;
for(int j=1;j<=cnt;++j){
if(i*prime[j]>n) ... | C++ | 0f7ceecdffe11f45d0c1d618ef3c6469 | 55ec12a7649ffdb99c1f1da5b61af0d9 | 1,300 | PASSED |
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
std::cin>>t;
while(t--){
long long n,temp;
std::cin>>n;
std::vector<long long> a;
std::vector<long long> b;
int count=0;
while(n%2==0){
n=n/2;
... | C++ | 0f7ceecdffe11f45d0c1d618ef3c6469 | 5fe88f17b40c8997c3bef5d45e8f8c42 | 1,300 | PASSED |
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
ll n,i,j;
ll g=1;
cin>>n;
int c=0;
if(n<24)
{
cout<<"NO\n";
continue;
}
for(i=2;i*i<=n;i++)
{
if(n%i==0)
{
//c++;
g=i;
j=(n/i);
... | C++ | 0f7ceecdffe11f45d0c1d618ef3c6469 | fd39d9092c00ec092885123abbfdac2e | 1,300 | PASSED |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long int n,i,k=0;
cin>>n;
long long int p=sqrt(n);
long long int a[3]={0};
for(i=2;i<p;i++)
{
if(n%i==0)
{
n=n/i;
... | C++ | 0f7ceecdffe11f45d0c1d618ef3c6469 | ef8d649bbe70caceca157cdab502bc68 | 1,300 | PASSED |
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "rt", stdin);
freopen("output.txt", "w", stdout);
#endif
fast
int t;cin>>t;
while(t--){
int n;cin>>n;
int temp=n, a=0, b=0, c=0;bool flag=false;
f... | C++ | 0f7ceecdffe11f45d0c1d618ef3c6469 | 56aa24f02a348ad13fbe4f716f521d54 | 1,300 | PASSED |
#include <bits/stdc++.h>
using namespace std;
int main() {
int q;
cin >> q;
for (int i = 0; i < q; ++i) {
int n;
cin >> n;
set<int> used;
for (int i = 2; i * i <= n; ++i) {
if (n % i == 0) {
used.insert(i);
n /= i;
break;
}
}
for (int i = 2; i * i <= n; ++i) {
if (n % i == 0 && !... | C++ | 0f7ceecdffe11f45d0c1d618ef3c6469 | d5511a2ee07e7a24d10d0b069f3cb28b | 1,300 | PASSED |
#include<bits/stdc++.h>
using namespace std;
#define boost() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define ll long long
#define fo(i,n) for(ll i=0;i<n;i++)
#define mem(x,y) memset(x, y, sizeof(x))
#define F first
#define S second
typedef pair<int, int> pii;
typedef pair<ll, ll> pl... | C++ | 0f7ceecdffe11f45d0c1d618ef3c6469 | b0eb285d4cb5706aea8f163213488486 | 1,300 | PASSED |
#include<bits/stdc++.h>
using namespace std;
#define boost() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define ll long long
#define fo(i,n) for(ll i=0;i<n;i++)
#define mem(x,y) memset(x, y, sizeof(x))
#define F first
#define S second
typedef pair<int, int> pii;
typedef pair<ll, ll> pl... | C++ | 0f7ceecdffe11f45d0c1d618ef3c6469 | c9196a65312230adcfa6348c86a56ece | 1,300 | PASSED |
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
int q;
cin >> q;
for (int i = 0; i < q; ++i) {
int n;
cin >> n;
set<int> used;
for (int i = 2; i * i <= n; ++i) {
if (n % i == 0 && !used.count(i)) ... | C++ | 0f7ceecdffe11f45d0c1d618ef3c6469 | 806f347efdd10bfd7de0c2410c2d5753 | 1,300 | PASSED |
#include <bits/stdc++.h>
#ifdef TOPOLOGY
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
using namespace std;
int n, m, k, depth[250003], md, sz, id[250003], vis[250003], pr[250003], tc;
vector<int> graph[250003];
vector<vector<int>> cycles, paths;
vector<int> path;
int dfs(int node, i... | C++ | 2136f0aed9da00c3f991235f5074f71e | ab1063df480a90bcdc629ae98c609594 | 2,700 | PASSED |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) begin(a), end(a)
#define has(a, b) (a.find(b) != a.end())
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)... | C++ | 2136f0aed9da00c3f991235f5074f71e | c1d33fae3ac82007fc15c177aaa3671f | 2,700 | PASSED |
#include <bits/stdc++.h>
#define endl '\n'
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define SZ(x) ((int)x.size())
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2... | C++ | 2136f0aed9da00c3f991235f5074f71e | c20ac600c9f08694d442525f28c0f7b6 | 2,700 | PASSED |
//be naame khodaa
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second
#define pb push_back
#define sz(x) ((int)(x).size())
inline int in(){ int x, y; y = scanf("%d", &x); return x; }
const int N = 250*1000 + 5;
bo... | C++ | 2136f0aed9da00c3f991235f5074f71e | e8fa7f10157f8320eeaadf66def3780b | 2,700 | PASSED |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
class Solution {
vector<int> leaves, in, out, dep, par;
vector<vector<int>> g;
int n, m, k;
void dfs(int u = 0) {
static int cur = 0;
int chCnt = 0;
in[u] = cur;
for (int v : g[u]) {
if (in[v] == -1) ++chCnt, par[v] = u, d... | C++ | 2136f0aed9da00c3f991235f5074f71e | 8bc894310ade765806032f3da55cac97 | 2,700 | PASSED |
#include <cstdio>
#include <stdlib.h>
using namespace std;
struct node{
int to;
node *next;
}*nd[250005];
int i,j,m,n,k,x,y,v,temp,pt;
int father[250005],first[250005],second[250005];
int ans[250005],cnt;
long long dep[250005];
bool visit[250005],leaf[250005];
void addd(int u,int v){
node *p=new node();
p->to=v;
p... | C++ | 2136f0aed9da00c3f991235f5074f71e | de040869b60ea8334e31d9c44bd6796e | 2,700 | PASSED |
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000005;
int n,m,K,lnk[maxn],son[2*maxn],nxt[2*maxn],tot,dep[maxn],fa[maxn],inn[maxn],maxid;
bool vis[maxn];
void adde(int x,int y){son[++tot]=y,nxt[tot]=lnk[x],lnk[x]=tot;}
void dfs(int x){
if (dep[x]>dep[maxid]) maxid=x;
vis[x]=1;
for (int j=lnk[... | C++ | 2136f0aed9da00c3f991235f5074f71e | 54be75970f066a5bf27684363459aeb2 | 2,700 | PASSED |
/*program by mangoyang*/
#include<bits/stdc++.h>
#define inf ((ll)(1e17))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
int ch = 0, f = 0; x = 0;
for(; !isdigit(ch); ch = getchar()) if(ch... | C++ | 2136f0aed9da00c3f991235f5074f71e | b3aa49e250d9cb86ce3b40f909f7a0da | 2,700 | PASSED |
#include <bits/stdc++.h>
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
using namespace std;
typedef vector<int>vi;
const int M=500005;
int k,n,m,u,v,to[M],p[M],lvl[M],deg[M];
vi adj[M];
bitset<M>vis;
int dfs(int u){
int mx=0;
to[u]=-1;
vis[u]=1;
for(int v:adj[u])
if(!vis[v]){
p[v]=u;
... | C++ | 2136f0aed9da00c3f991235f5074f71e | 2d60c80c98f99988fe276d9a2be90285 | 2,700 | PASSED |
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const ... | C++ | 2136f0aed9da00c3f991235f5074f71e | 120e586bd2f8cf1289e28fe663deba2b | 2,700 | PASSED |
// luogu-judger-enable-o2
#include <bits/stdc++.h>
#define LL long long
#define Maxn 200500
using namespace std;
template <typename tn> void read(tn &a){
tn x = 0, f = 1; char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
a = x * f;
}... | C++ | 752c583a1773847504bf0d50b72a9dda | b7ab55924d7b25d05e42812090b43e12 | 2,400 | PASSED |
#include <bits/stdc++.h>
using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;
#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)
const int N = 200000 + 10;
class AcAutomaton {
public:
static const int kMaxN = 200000 + 10;
static const int kMaxT = ... | C++ | 752c583a1773847504bf0d50b72a9dda | 9363e11dd1bfdb0ed7cf98e6dfe4d07c | 2,400 | PASSED |
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <deque>
#include <queue>
using namespace std;
#define enable_ll
#ifdef enabl... | C++ | 752c583a1773847504bf0d50b72a9dda | a13f2f22a80568d8435e037146e49d88 | 2,400 | PASSED |
#define ENABLE_LL
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;
#ifdef ENABLE_LL
#define int long long
#endif
#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld... | C++ | 752c583a1773847504bf0d50b72a9dda | fdcc0c2fceda226633bf90866374e222 | 2,400 | PASSED |
#include <bits/stdc++.h>
using namespace std;
// #define ls now << 1
// #define rs now << 1 | 1
// #define PB push_back
// #define MP make_pair
#define int long long
// #define us unsigned
// #define LL long long
const int N = 2e5;
// const int M = 5e4;
// #define re register
// const int mod = 1e9 + 7;
// const dou... | C++ | 752c583a1773847504bf0d50b72a9dda | ce2c0564550ccc7622fc8661d8698536 | 2,400 | PASSED |
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std ;
const int N = 2e5 + 5 ;
int n,tot[2]={0,0} ;
char S[N],c[N] ;
int F[N][2] ;
struct AC_auto {
int ch[26] ;
int fail,end ;
}t[N][2] ;
void Insert(char *str,int k) {
int p=0,len=strlen(str) ;
for(int i=0;i<l... | C++ | 752c583a1773847504bf0d50b72a9dda | 5d4562bdda0a4b5d975546e8a6a5af52 | 2,400 | PASSED |
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<deque>
#include<numeric>
#include<stack>
#include<ctime>
using namespace std;
typedef long long ll;
#define eps 1e-8
#define pi acos(-1.0)
temp... | C++ | 752c583a1773847504bf0d50b72a9dda | 43868850f9a569618963a96b2d5659e4 | 2,400 | PASSED |
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 2 * 1e5 + 10;
char s[N], t[N];
int trie[N][26][2], tot[2], size[N][2];
inline void insert(char *a, int len, bool k) {
int p = 0;
for (int i = 0; i < len; i++) {
int c = a[i] - 'a';
if (!... | C++ | 752c583a1773847504bf0d50b72a9dda | 11f7a33e8fc1a6fc534649d9ecfa999a | 2,400 | PASSED |
#include <bits/stdc++.h>
const int maxn = 2e5 + 5;
using namespace std;
struct Trie{
int nex[maxn][26], fail[maxn], end[maxn];
int root, p;
inline int newnode() {
for (int i = 0; i < 26; ++i) {
nex[p][i] = -1;
}
end[p++] = 0;
return p - 1;
}
inline void in... | C++ | 752c583a1773847504bf0d50b72a9dda | 9df8fd979f77d57260e171e07ae12721 | 2,400 | PASSED |
//
// Created by Feng Xinyu on 8/14/19.
//
#include <iostream>
#include <queue>
#include <string.h>
#include <algorithm>
using namespace std;
#define MAXN 200005
char t[MAXN], s[MAXN];
int n;
class AC_Machine {
public:
int trie[MAXN][26], f[MAXN], cnt[MAXN], dp[MAXN], states;
public:
AC_Machine() {
... | C++ | 752c583a1773847504bf0d50b72a9dda | b9082c74362ff79f773cb2e9a08fd677 | 2,400 | PASSED |
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1000000000")
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <complex>
#include <string>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cmath>
... | C++ | da1206100811e4a51b9453babfa2c821 | c4cc3a9e5f9d8ba5d5c89bec1a96ae94 | 2,800 | PASSED |
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <math.h>
using namespace std;
#define inf 1000000010
#define ll int
#define N 200005
#define L(x) (x<<1)
#define R(x) (x<<1|1)
inline ll Mid(ll a,ll b){return (a+b)>>1;}
ll n;
struct no... | C++ | da1206100811e4a51b9453babfa2c821 | a37ba335b744dc2a79ede953999fadb3 | 2,800 | PASSED |
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <math.h>
using namespace std;
#define inf 1000000010
#define ll int
#define N 200005
#define L(x) (x<<1)
#define R(x) (x<<1|1)
inline ll Mid(ll a,ll b){return (a+b)>>1;}
ll n;
struct no... | C++ | da1206100811e4a51b9453babfa2c821 | 47367e33615b9f7ac2e880f2308e3e72 | 2,800 | PASSED |
/* **********************************************
Author : wuyiqi
Created Time: 2013/9/1 15:37:26
File Name : ruocai.cpp
*********************************************** */
#include <cstdio>
#include <set>
#include <cstring>
#include <algorithm>
#define L x->c[0]
#define R x->c[1]
#define KT root->c[1]->c[0]... | C++ | da1206100811e4a51b9453babfa2c821 | d6c20688d1e00a12a5901844212bed0d | 2,800 | PASSED |
#include<cstdio>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const int maxn = 200010;
int Max[maxn<<2];
int ansx,ansy;
inline void pushup(int rt){
Max[rt]=max(Max[rt<<1],Max[rt<<1|1]);
}
void update(int pos,int val,int l... | C++ | da1206100811e4a51b9453babfa2c821 | 3e694660d3185e593c853d51212c8c92 | 2,800 | PASSED |
#include<cstdio>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const int maxn = 200010;
int Max[maxn<<2];
int ansx,ansy;
inline void pushup(int rt){
Max[rt]=max(Max[rt<<1],Max[rt<<1|1]);
}
void update(int pos,int val,int l... | C++ | da1206100811e4a51b9453babfa2c821 | 873bbda1975ee6b9e014439923a0075a | 2,800 | PASSED |
// #include <assert.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;
namespace detail {
const int maxn = 200001;
// Point
struct Point
{
int x, y;
Point* next;
};
typedef Point* PointPtr;
template<typename T>
void nullify(T* pointer... | C++ | da1206100811e4a51b9453babfa2c821 | 7074a528e6e0325983f4a4347e934508 | 2,800 | PASSED |
// #include <assert.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;
namespace detail {
const int maxn = 200001;
// Point
struct Point
{
int x, y;
Point* next;
};
typedef Point* PointPtr;
template<typename T>
void nullify(T* pointer... | C++ | da1206100811e4a51b9453babfa2c821 | cc6ed1a225d487b0aa897603d13a4c4f | 2,800 | PASSED |
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
const int maxn=200105;
int a[maxn];
int bit[maxn];
int get(int p,int n){
int le,ri,mid;
le=1;
ri=n;
while(le<=ri){
mid=(le+ri)/2;
if(a[mid]<=p) le=mid+1;
else ri=mid-1;
... | C++ | da1206100811e4a51b9453babfa2c821 | 7716f0ea8f1869816d94b2d808c2cab0 | 2,800 | PASSED |
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define X first
#define Y second
typedef pair<int,int> PII;
vector<PII> u;
PII a[200000];
char str[200005];
int locate(PII x){
return lower_bound(u.begin(),u.end(),x)-u.begin();
}
class SegTree{
public:
int top[524288];
void m... | C++ | da1206100811e4a51b9453babfa2c821 | a52dacc3845266e822f532089d8b8228 | 2,800 | PASSED |
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long int ll;
/*bool compare_function(const pair<int, int> a, const pair<int, int> b) {
return a.first < b.first;
}
use case
sort(V.... | C++ | 3b5b8c54dc9956e7060c7f154eebd063 | 9ed356becce3012b8d2a4854384e8dad | 2,100 | PASSED |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 10;
int a[maxn],topmost; int alright[maxn];
ll sum[maxn];
bool compare(int x, int y, int z)
{
return (sum[y] - sum[x]) * (z - y) > (sum[z] - sum[y]) * (y - x);
}
int main()
{
int n;
sum[0]=0;
scanf("%d", &n);
for(int i ... | C++ | 3b5b8c54dc9956e7060c7f154eebd063 | c7fd28fa8c4cf77515da9dc4054f8829 | 2,100 | PASSED |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
const int maxn = 1e6 + 5;
int n, a[maxn];
struct point {
ll sum, len;
};
int main() {
ios_base::... | C++ | 3b5b8c54dc9956e7060c7f154eebd063 | 08306e40e27043bf930bd94866611330 | 2,100 | PASSED |
//
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define f first
#define s second
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0,... | C++ | 3b5b8c54dc9956e7060c7f154eebd063 | b752cd76cc35abb41cb9b20558b670c3 | 2,100 | PASSED |
#include <bits/stdc++.h>
#define DBG(x) cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
int n, m = 0, sz[N]; double avg[N];
int main() {
scanf("%d", &n);
for (int i = 1, x; i <= n; i++) {
scanf("%d", &x);
avg[++m] = 1.0 * x;
sz[m] = 1;
while (m >... | C++ | 3b5b8c54dc9956e7060c7f154eebd063 | 3a472bff5b3c651a2797917e595f1344 | 2,100 | PASSED |
#include<cstdio>
using namespace std;
const int N=(int)1e6+5;
typedef long long ll;
int q[N],top,n;
ll a[N];
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
for(int i=1;i<=n;i++) a[i]+=a[i-1];
q[++top]=0;
for(int i=1;i<=n;i++){
while(top>1 && (a[i]-a[q[top]])*(q[top]-... | C++ | 3b5b8c54dc9956e7060c7f154eebd063 | 0d8ae384fe11ee850fbcbe4a86182155 | 2,100 | PASSED |
#include <bits/stdc++.h>
using namespace std;
double sum[1000005];
int p[1000005];
template<typename T> inline void read(T &x){
int ch = getchar(); x = 0;
bool f = false;
while((ch < '0' || ch > '9') && ch != '-') ch = getchar();
if(ch == '-'){f = true; ch = getchar();}
while(ch >= '0' && ch <= '9'){x = x * 10 + c... | C++ | 3b5b8c54dc9956e7060c7f154eebd063 | 80cd97afd6640ff95835781ac2d0da69 | 2,100 | PASSED |
#include <bits/stdc++.h>
using namespace std;
double sum[1000005];
int p[1000005];
int main()
{
int n; scanf("%d",&n);
for(int i = 1; i <= n; i++) {
int num; scanf("%d",&num);
sum[i] = sum[i-1] + num;
}
int top = 0;
for(int i = 1; i <= n; i++) {
while(top and ((sum[p[top]] - ... | C++ | 3b5b8c54dc9956e7060c7f154eebd063 | b932bb4408a03b7b425f956d34d6f1fd | 2,100 | PASSED |
#include <bits/stdc++.h>
using namespace std;
double sum[1000005];
int p[1000005];
int main()
{
int n; cin >> n;
for(int i = 1; i <= n; i++) {
int num; cin >> num;
sum[i] = sum[i-1] + num;
}
int top = 0;
for(int i = 1; i <= n; i++) {
while(top && (sum[p[top]]-sum[p[top-1]])/(... | C++ | 3b5b8c54dc9956e7060c7f154eebd063 | adf806e98bf9c1f07a78f1177352b898 | 2,100 | PASSED |
#include <bits/stdc++.h>
using namespace std;
double sum[1000005];
int p[1000005];
int main()
{
int n; cin >> n;
for(int i = 1; i <= n; i++) {
int num; cin >> num;
sum[i] = sum[i-1] + num;
}
int top = 0;
for(int i = 1; i <= n; i++) {
while(top and ((sum[p[top]] - sum[p[top-1]... | C++ | 3b5b8c54dc9956e7060c7f154eebd063 | 2edede64da7b4ad56fa184dce7091220 | 2,100 | PASSED |
n, a, b, k = [int(i) for i in input().split()]
st = input()
l = (n + 1) // k
s = 0
mod = 1000000009
def f_pow(a, k):
if k == 0:
return 1
if k % 2 == 1:
return f_pow(a, k - 1) * a % mod
else:
return f_pow(a * a % mod, k // 2) % mod
def rev(b):
return f_pow(b, mod - 2)
q = f_pow... | Python | 607e670403a40e4fddf389caba79607e | be3a8a2ba6790f9107422997c89f2f4f | 1,800 | PASSED |
import queue
def readTuple():
return input().split()
def readInts():
return tuple(map(int, readTuple()))
def egcd(aa, bb):
lastremainder, remainder = abs(aa), abs(bb)
x, lastx, y, lasty = 0, 1, 1, 0
while remainder:
lastremainder, (quotient, remainder) = remainder, divmod(lastremainder, re... | Python | 607e670403a40e4fddf389caba79607e | fd193afa8ccf13e08a8406062aa89fe8 | 1,800 | PASSED |
n, a, b, k = map(int, input().split() )
s = input()
mod = (int)( 1e9 + 9 )
ans = 0
t = (int)( (n + 1) / k )
def modInverse(a):
return pow(a, mod - 2, mod)
i = 0
for ind in range( len(s) ):
first = ( pow(a, n - i, mod ) * pow( b, i, mod ) ) % mod
num = ( pow( b, k, mod ) * modInverse( pow(a, k, mod... | Python | 607e670403a40e4fddf389caba79607e | dab21646bb7a5fa2ab8eedc4e5ffce95 | 1,800 | PASSED |
MOD = 1000000009
def xpow(desk,step):
ret=1
desk=desk%MOD
while step:
if(step%2):
ret=(ret*desk)%MOD
step=step//2
desk = (desk * desk) % MOD
return ret
if __name__ == '__main__':
n,a,b,k=map(int,input().split())
s=input()
base=0
for i in range(0,k):
... | Python | 607e670403a40e4fddf389caba79607e | 89b8985e64dff167e063ef841141f816 | 1,800 | PASSED |
MOD = 1000000009
def xpow(desk,step):
ret=1
desk=desk%MOD
while step:
if(step%2):
ret=(ret*desk)%MOD
step=step//2
desk = (desk * desk) % MOD
return ret
if __name__ == '__main__':
n,a,b,k=map(int,input().split())
s=input()
base=0
for i in range(0,k):
... | Python | 607e670403a40e4fddf389caba79607e | 45c991034ee442674506e5682d533604 | 1,800 | PASSED |
def xpow(desk,step):
ret=1
while step:
if(step%2):
ret=(ret*desk)%MOD
step=step//2
desk = (desk * desk) % MOD
return ret
if __name__ == '__main__':
MOD=1000000009
n,a,b,k=map(int,input().split())
s=input()
base=0
for i in range(0,k):
base = (ba... | Python | 607e670403a40e4fddf389caba79607e | 618812d0b7c009646fd1b448580fbb5e | 1,800 | PASSED |
def xpow(desk,step):
ret=1
while step:
if(step%2):
ret=(ret*desk)%MOD
step=step//2
desk = (desk * desk) % MOD
return ret
def fix(a):
if(a == '+'):
return 1
else:
return -1
if __name__ == '__main__':
MOD=1000000009
n,a,b,k=map(int,input().s... | Python | 607e670403a40e4fddf389caba79607e | 22bf68b878652e485c4da064465fea6f | 1,800 | PASSED |
mod = 1000000009
def inv(x):
return pow(x,mod - 2, mod)
n, a, b, k = map(int, input().split())
s = input()
q = pow(b, k, mod) * inv(pow(a, k, mod))
t = 0
for i in range(k):
sgn = 1 if s[i] == '+' else -1
t += sgn * pow(a, n - i, mod) * pow(b, i, mod)
t %= mod
t += mod
t %= mod
print(((t * (1 - ... | Python | 607e670403a40e4fddf389caba79607e | 52542fda37ce1589fd8bb027d7064b71 | 1,800 | PASSED |
MOD = 1000000009
def inv(n):
return pow(n, MOD - 2, MOD)
n, a, b, k = map(int, input().split())
q = (n + 1) // k
string = input()
s = []
for char in string:
if char == "+": s.append(1)
else: s.append(-1)
res = 0 # final answer
for i in range(k):
res += (s[i] * pow(a, n - i, MOD) * pow(b, i, MOD)... | Python | 607e670403a40e4fddf389caba79607e | 9a9911d12c26ff3dba3cb3d3c12f57e2 | 1,800 | PASSED |
MOD = 1000000009
def inv(n): # Calculate inverse of n modulo MOD
return pow(n, MOD - 2, MOD)
n, a, b, k = map(int, input().split()) # first line of input
q = (n + 1) // k
string = input() # second line of input
s = [] # list for storing +1 and -1 as and when + or - occur in the string
for char in string:
i... | Python | 607e670403a40e4fddf389caba79607e | 6c3faf40f565897b66ffa0ecf398ae5e | 1,800 | PASSED |
def read_nums():
return [int(x) for x in input().split()]
class UnionFind:
def __init__(self, size):
self._parents = list(range(size))
# number of elements rooted at i
self._sizes = [1 for _ in range(size)]
def _root(self, a):
while a != self._parents[a]:
self... | Python | e52ec2fa5bcf5d2027d57b0694b4e15a | d045b0ecd6aaad78a2574780f55d22a1 | 1,900 | PASSED |
from sys import stdin, stdout
input = stdin.readline
import gc, os
from os import _exit
gc.disable()
def put():
return map(int, input().split())
def find(i):
if i==p[i]:
return i
p[i]=find(p[i])
return p[i]
def union(i,j):
if rank[i]>rank[j]:
i,j = j,i
p[i]=j
if rank[i]==r... | Python | e52ec2fa5bcf5d2027d57b0694b4e15a | 0ce28d52e668084f2bb5e5cb7379cb3e | 1,900 | PASSED |
n, m = map(int, input().split())
a = list(map(int, input().split()))
e = []
for _ in range(m) :
u, v, w = map(int, input().split())
e.append((u-1, v-1, w))
a = sorted(zip(a, range(n)), key = lambda x : x[0])
for i in range(1, n) :
e.append((a[0][1], a[i][1], a[0][0] + a[i][0]))
fa = list(range(n))
rk = [... | Python | e52ec2fa5bcf5d2027d57b0694b4e15a | 2f855ea8cd6682ec1b1059af3817957d | 1,900 | PASSED |
def main():
n,m=map(int,raw_input().split())
a=list(map(int,raw_input().split()))
b=min(a)
c=a.index(b)
edges=[0]*(n+m)
for i in xrange(n):
edges[i]=(b+a[i],c,i)
for i in xrange(m):
x,y,z=map(int,raw_input().split())
edges[-i-1]=(z,x-1,y-1)
edges[c]=(3000000000000... | Python | e52ec2fa5bcf5d2027d57b0694b4e15a | 1d3e89845293a97b583289d7acaf5849 | 1,900 | PASSED |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.