Submission #59093

# Submission time Handle Problem Language Result Execution time Memory
59093 2018-07-20T13:48:35 Z WA_TLE Gondola (IOI14_gondola) C++14
25 / 100
55 ms 4844 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>
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=1000000009;
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();}
#include "gondola.h"
int valid(int n, int inputSeq[]){
	map<int,bool>use;
	int i,ofset=-1;
	for(i=0;i<n;i++){
		if(use[inputSeq[i]]){return 0;}
		use[inputSeq[i]]=1;
		if(inputSeq[i]>n){continue;}
		int itf=(i+n-inputSeq[i])%n;
		if(ofset==-1||ofset==itf){ofset=itf;}
		else{return 0;}
	}
	return 1;
}

//----------------------

int replacement(int n, int gondolaSeq[], int replacementSeq[]){
	int i,dai=0,ofset=0,ziyu=0;
	for(i=0;i<n;i++){
		if(maxeq(dai,gondolaSeq[i])){ziyu=i;}
		if(gondolaSeq[i]>n){continue;}
		int itf=(i+n-gondolaSeq[i])%n;
		ofset=itf;
	}
	//場所-ofset=元のゴンドラ
	for(i=0;i<dai-n;i++){replacementSeq[i]=-1;}
	ziyu=(n+n+ziyu-ofset-1)%n +1;
	for(i=0;i<n;i++){replacementSeq[gondolaSeq[i]-n-1]=(n+n+i-ofset-1)%n +1;}
	for(i=0;i<dai-n;i++){
		if(replacementSeq[i]==-1){
			replacementSeq[i]=ziyu;
			ziyu=i+n+1;
		}
	}
	replacementSeq[dai-n-1]=ziyu;
	return dai-n;
}

//----------------------

int countReplacement(int n, int inputSeq[]){
	if(!valid(n,inputSeq)){return 0;}
	llint dai=0,ans=n,zi=0,i;
	for(i=0;i<n;i++){
		maxeq(dai,inputSeq[i]);
		if(inputSeq[i]<=n){ans=1;}
	}
	sort(inputSeq,inputSeq+n);
	int mae=dai+1;
	for(i=n-1;i>=0&&inputSeq[i]>=n;i--){
		int dis=mae-inputSeq[i]-1;
		mae=inputSeq[i];
		llint bg=zi;
		for(int h=0;h<=30;h++){
			if(dis&(1<<h)){ans*=bg;ans%=mod;}
			bg*=bg;bg%=mod;
		}
		zi++;
	}
	int dis=mae-n-1;
	llint bg=zi;
		for(int h=0;h<=30;h++){
			if(dis&(1<<h)){ans*=bg;ans%=mod;}
			bg*=bg;bg%=mod;
		}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 448 KB Output is correct
5 Correct 2 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 484 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 22 ms 2332 KB Output is correct
7 Correct 14 ms 2332 KB Output is correct
8 Correct 37 ms 4128 KB Output is correct
9 Correct 12 ms 4128 KB Output is correct
10 Correct 52 ms 4812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4812 KB Output is correct
2 Correct 2 ms 4812 KB Output is correct
3 Correct 3 ms 4812 KB Output is correct
4 Correct 3 ms 4812 KB Output is correct
5 Correct 3 ms 4812 KB Output is correct
6 Correct 23 ms 4812 KB Output is correct
7 Correct 17 ms 4812 KB Output is correct
8 Correct 40 ms 4812 KB Output is correct
9 Correct 12 ms 4812 KB Output is correct
10 Correct 55 ms 4844 KB Output is correct
11 Correct 2 ms 4844 KB Output is correct
12 Correct 2 ms 4844 KB Output is correct
13 Correct 9 ms 4844 KB Output is correct
14 Correct 3 ms 4844 KB Output is correct
15 Correct 18 ms 4844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4844 KB Output is correct
2 Correct 2 ms 4844 KB Output is correct
3 Correct 2 ms 4844 KB Output is correct
4 Correct 3 ms 4844 KB Output is correct
5 Correct 2 ms 4844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4844 KB Output is correct
2 Correct 2 ms 4844 KB Output is correct
3 Correct 3 ms 4844 KB Output is correct
4 Correct 3 ms 4844 KB Output is correct
5 Correct 2 ms 4844 KB Output is correct
6 Correct 3 ms 4844 KB Output is correct
7 Runtime error 3 ms 4844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4844 KB Output is correct
2 Correct 3 ms 4844 KB Output is correct
3 Correct 2 ms 4844 KB Output is correct
4 Correct 2 ms 4844 KB Output is correct
5 Correct 2 ms 4844 KB Output is correct
6 Correct 3 ms 4844 KB Output is correct
7 Runtime error 4 ms 4844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4844 KB Output isn't correct
2 Halted 0 ms 0 KB -