Submission #70123

# Submission time Handle Problem Language Result Execution time Memory
70123 2018-08-22T11:34:08 Z WA_TLE Tropical Garden (IOI11_garden) C++14
69 / 100
5000 ms 38788 KB
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000000;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//O(mQlogGは通る!)
//void answer(int X){cout<<X<<endl;}
void answer(int X);
void count_routes(int N,int M,int P,int R[][2],int Q,int G[]){
	//まずはどのみちがどの道につながってますか
	static int dab[300000][30];
	//噴水から歩き始めるものの候補を調べる
	int h,i,j;
	static int best[150000];
	static bool seco[150000]={};
	static bool ok[300000]={0};
	for(i=0;i<N;i++){best[i]=-1;}
	for(i=0;i<M*2;i++){
		int a=R[i/2][0];
		int b=R[i/2][1];
		if(i%2){swap(a,b);}
		if(best[a]==-1){best[a]=i;}
		else if(!seco[a]){seco[a]=1;dab[best[a]^1][0]=i;}
		
		if(best[b]!=-1&&best[b]!=(i^1)){dab[i][0]=best[b];}
		if(b==P){ok[i]=1;}
	}
	for(i=0;i<N;i++){
		if(!seco[i]){dab[best[i]^1][0]=best[i];}
	}
	for(i=0;i<M*2;i++){
		int a=R[i/2][0];
		int b=R[i/2][1];
		if(i%2){swap(a,b);}
		int nex=dab[i][0];
		int c=R[nex/2][0];
		int d=R[nex/2][1];
		if(nex%2){swap(c,d);}
		//cout<<"a,b,nexa,nexb"<<a<<b<<c<<d<<endl;
	}
	for(h=1;h<30;h++){
		for(i=0;i<M*2;i++){dab[i][h]=dab[dab[i][h-1]][h-1];}
	}
	for(j=0;j<Q;j++){
		int K=G[j]-1;
		int ans=0;
		for(i=0;i<N;i++){
			int bas=best[i];
			for(h=0;h<30;h++){if(K&(1<<h)){bas=dab[bas][h];}}
			if(ok[bas]){ans++;}
		}
		//cerr<<endl;
		answer(ans);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 656 KB Output is correct
3 Correct 3 ms 636 KB Output is correct
4 Correct 7 ms 348 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 888 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 3 ms 632 KB Output is correct
9 Correct 7 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 656 KB Output is correct
3 Correct 3 ms 636 KB Output is correct
4 Correct 7 ms 348 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 888 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 3 ms 632 KB Output is correct
9 Correct 7 ms 2396 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 24 ms 6108 KB Output is correct
12 Correct 61 ms 13788 KB Output is correct
13 Correct 129 ms 22076 KB Output is correct
14 Correct 215 ms 36796 KB Output is correct
15 Correct 212 ms 38344 KB Output is correct
16 Correct 210 ms 34676 KB Output is correct
17 Correct 178 ms 34688 KB Output is correct
18 Correct 52 ms 13616 KB Output is correct
19 Correct 210 ms 37160 KB Output is correct
20 Correct 214 ms 38716 KB Output is correct
21 Correct 210 ms 34896 KB Output is correct
22 Correct 204 ms 35336 KB Output is correct
23 Correct 224 ms 38788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 656 KB Output is correct
3 Correct 3 ms 636 KB Output is correct
4 Correct 7 ms 348 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 888 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 3 ms 632 KB Output is correct
9 Correct 7 ms 2396 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 24 ms 6108 KB Output is correct
12 Correct 61 ms 13788 KB Output is correct
13 Correct 129 ms 22076 KB Output is correct
14 Correct 215 ms 36796 KB Output is correct
15 Correct 212 ms 38344 KB Output is correct
16 Correct 210 ms 34676 KB Output is correct
17 Correct 178 ms 34688 KB Output is correct
18 Correct 52 ms 13616 KB Output is correct
19 Correct 210 ms 37160 KB Output is correct
20 Correct 214 ms 38716 KB Output is correct
21 Correct 210 ms 34896 KB Output is correct
22 Correct 204 ms 35336 KB Output is correct
23 Correct 224 ms 38788 KB Output is correct
24 Correct 10 ms 428 KB Output is correct
25 Execution timed out 5034 ms 6212 KB Time limit exceeded
26 Halted 0 ms 0 KB -