답안 #126329

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126329 2019-07-07T12:03:32 Z groeneprof 크레이피쉬 글쓰는 기계 (IOI12_scrivener) C++11
60 / 100
1000 ms 117112 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;
const int N = 1000005;
//int ind[N];
char parent[N];
int depth[N];
int memo[N][23];
bool check[N][23];
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(check[i][h]){
		return memo[i][h];
	}
	check[i][h] = true;
	return memo[i][h] = f(f(i,h-1) , h-1);
}

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

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

void UndoCommands(int U) {
	H(U);
	parent[cur+1] = parent[cur-U];
	depth[cur+1] = depth[cur-U];
	memo[cur+1][0] = memo[cur-U][0];
	check[cur+1][0] = true;
	cur++;
}

char GetLetter(int P) {
	H(P);
	print();
	int res = cur;
	for(int h = 22; h>=0; h--){
		if(depth[f(res, h)]>P) res = f(res, h);
	}
	return parent[res];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 4 ms 760 KB Output is correct
3 Correct 4 ms 888 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 4 ms 888 KB Output is correct
6 Correct 3 ms 888 KB Output is correct
7 Correct 4 ms 888 KB Output is correct
8 Correct 4 ms 888 KB Output is correct
9 Correct 4 ms 888 KB Output is correct
10 Correct 3 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 289 ms 84836 KB Output is correct
2 Correct 251 ms 103356 KB Output is correct
3 Correct 285 ms 102720 KB Output is correct
4 Correct 351 ms 107512 KB Output is correct
5 Correct 386 ms 94892 KB Output is correct
6 Correct 285 ms 112292 KB Output is correct
7 Correct 446 ms 95864 KB Output is correct
8 Correct 356 ms 108152 KB Output is correct
9 Correct 294 ms 103928 KB Output is correct
10 Correct 224 ms 117112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 660 ms 77876 KB Output is correct
2 Correct 806 ms 66880 KB Output is correct
3 Correct 399 ms 85344 KB Output is correct
4 Correct 475 ms 73720 KB Output is correct
5 Correct 663 ms 99516 KB Output is correct
6 Correct 500 ms 103032 KB Output is correct
7 Correct 632 ms 102620 KB Output is correct
8 Execution timed out 1027 ms 86244 KB Time limit exceeded
9 Halted 0 ms 0 KB -