Submission #62560

# Submission time Handle Problem Language Result Execution time Memory
62560 2018-07-29T06:04:43 Z zetapi Crayfish scrivener (IOI12_scrivener) C++14
0 / 100
1000 ms 63216 KB
#include <bits/stdc++.h>
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll  long long
#define itr ::iterator 

typedef pair<int,int>  pii;

const int MAX=1e6+99;

vector<char> X;
int ind,tot,arr[MAX],height[MAX],Parent[MAX][25];

void Init() 
{

}

void TypeLetter(char L) 
{
	X.pb(L);
	Parent[++ind][0]=arr[tot++];
	height[ind]=height[Parent[ind][0]]+1;
	for(int A=1;A<25;A++)
		Parent[ind][A]=Parent[Parent[ind][A-1]][A-1];
	arr[tot]=ind;
	return ;
}

void UndoCommands(int U) 
{
	arr[++tot]=arr[tot-U];
	return ;
}

char GetLetter(int P) 
{
	int res=arr[tot];
	for(int A=24;A>=0;A--)
	{
		if(height[Parent[res][A]]>P)
			res=Parent[res][A];
	}
	return X[res];
}

/*signed main()
{
	ios_base::sync_with_stdio(false);

	
	TypeLetter('a');
	TypeLetter('b');
	TypeLetter('d');
	UndoCommands(2);
	UndoCommands(1);
	cout<<GetLetter(2);
	return 0;
}*/

Compilation message

scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:34:6: warning: operation on 'tot' may be undefined [-Wsequence-point]
  arr[++tot]=arr[tot-U];
      ^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 692 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 63216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 63216 KB Time limit exceeded
2 Halted 0 ms 0 KB -