Submission #126215

# Submission time Handle Problem Language Result Execution time Memory
126215 2019-07-07T09:20:36 Z groeneprof Crayfish scrivener (IOI12_scrivener) C++14
0 / 100
1000 ms 145164 KB
#include <bits/stdc++.h>
#define P(x) do {if(debug) cout << x << endl;} while(false)
#define H(x) P(#x << ": " << x)
#define FR(i, a, b) for(int i = (a); i < (b); ++i)
#define F(i, n) FR(i, 0, n)
using namespace std;
const bool debug = 0;
const int inf = 1e9;
int N = 1000005;
vector<int> ind;
vector<char> parent;
vector<int> depth;
vector<vector<int> > memo;
int cur;

int root(int a){
	if(a==ind[a]){
		return a;
	}
	return ind[a] = root(ind[a]);
}

void print(){
	if(debug){
		cout<<"ind: ";
		F(i, cur+1) cout<<ind[i]<<" ";
		cout<<"\nparent: ";
		F(i, cur+1) cout<<parent[i]<<" ";
		cout<<"\ndepth: ";
		F(i, cur+1) cout<<depth[i]<<" ";
		cout<<"\nmemo: ";
		F(i, cur+1) cout<<memo[i][0]<<" ";

	}
}

int f(int i, int h){
	if(memo[i][h]!=-1){
		return memo[i][h];
	}
	return memo[i][h] = f(f(i,h-1) , h-1);
}

void Init() {
	ind = {0};
	parent = {'\\'};
	depth = {0};
	P("I");
	memo.resize(N, vector<int> (23, -1));
	memo[0][0] = 0;
	P("II");
	cur = 0;
}

void TypeLetter(char L) {
	H(L);
	int n = cur+1;
	ind.push_back(n);
	parent.push_back(L);
	memo[n][0] = root(cur);
	depth.push_back(depth[root(cur)]+1);
	//cout<<endl;
	cur = n;
}

void UndoCommands(int U) {
	H(U);
	ind.push_back(cur-U);
	parent.push_back('/');
	depth.push_back(-1);
	cur = cur+1;
}

char GetLetter(int P) {
	H(P);
	print();
	int res = root(cur);
	for(int h = 22; h>=0; h--){
		if(depth[root(f(res, h))]>P+1) res = f(res, h);
	}
	return parent[res];
}
# Verdict Execution time Memory Grader output
1 Incorrect 160 ms 133388 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 164 ms 133432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 182 ms 133444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 492 ms 144640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 145164 KB Time limit exceeded
2 Halted 0 ms 0 KB -