Submission #121247

# Submission time Handle Problem Language Result Execution time Memory
121247 2019-06-26T09:08:15 Z baluteshih Crayfish scrivener (IOI12_scrivener) C++14
60 / 100
1000 ms 119284 KB
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

vector<vector<pair<int,char>>> v(1000005,vector<pair<int,char>>());
int Len[1000005],pa[20][1000005],ti[1000005],lg=19,t;

void Init(){
	t=0,Len[0]=-1;
}

int finds(int x)
{
	if(ti[x]==x) return x;
	return ti[x]=finds(ti[x]);
}

void TypeLetter(char L) 
{
	++t,ti[t]=t,Len[t]=Len[finds(t-1)]+1,v[Len[t]].pb(MP(t,L));
	pa[0][t]=finds(t-1);
	for(int i=1;i<=lg;++i)
		pa[i][t]=pa[i-1][pa[i-1][t]];
}

void UndoCommands(int U)
{
	++t,ti[t]=finds(t-U-1),Len[t]=Len[finds(t-U-1)];
}

char GetLetter(int P)
{
	int x=finds(t);
	for(int i=__lg(t);i>=0;--i)
		if(Len[pa[i][x]]>=P)
			x=pa[i][x];
	if(Len[pa[0][x]]>=P) 
		x=pa[0][x];
	auto p=lower_bound(ALL(v[P]),MP(x,(char)('a'-1)));
	return p->S;
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 23936 KB Output is correct
2 Correct 24 ms 24064 KB Output is correct
3 Correct 24 ms 24192 KB Output is correct
4 Correct 23 ms 23928 KB Output is correct
5 Correct 26 ms 24032 KB Output is correct
6 Correct 29 ms 24060 KB Output is correct
7 Correct 22 ms 23936 KB Output is correct
8 Correct 22 ms 23936 KB Output is correct
9 Correct 22 ms 24064 KB Output is correct
10 Correct 22 ms 24064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 23936 KB Output is correct
2 Correct 23 ms 24064 KB Output is correct
3 Correct 22 ms 24028 KB Output is correct
4 Correct 27 ms 24036 KB Output is correct
5 Correct 24 ms 23936 KB Output is correct
6 Correct 23 ms 23980 KB Output is correct
7 Correct 23 ms 23936 KB Output is correct
8 Correct 24 ms 23936 KB Output is correct
9 Correct 23 ms 23936 KB Output is correct
10 Correct 23 ms 23936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 24292 KB Output is correct
2 Correct 31 ms 24184 KB Output is correct
3 Correct 26 ms 24312 KB Output is correct
4 Correct 24 ms 24440 KB Output is correct
5 Correct 26 ms 24308 KB Output is correct
6 Correct 25 ms 24448 KB Output is correct
7 Correct 24 ms 24448 KB Output is correct
8 Correct 25 ms 24448 KB Output is correct
9 Correct 27 ms 24576 KB Output is correct
10 Correct 29 ms 24448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 526 ms 95792 KB Output is correct
2 Correct 561 ms 110548 KB Output is correct
3 Correct 486 ms 106304 KB Output is correct
4 Correct 457 ms 107880 KB Output is correct
5 Correct 640 ms 101132 KB Output is correct
6 Correct 446 ms 119284 KB Output is correct
7 Correct 644 ms 103576 KB Output is correct
8 Correct 559 ms 118276 KB Output is correct
9 Correct 656 ms 112448 KB Output is correct
10 Correct 275 ms 113860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 899 ms 89036 KB Output is correct
2 Execution timed out 1089 ms 79924 KB Time limit exceeded
3 Halted 0 ms 0 KB -