답안 #121305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
121305 2019-06-26T09:59:20 Z baluteshih 크레이피쉬 글쓰는 기계 (IOI12_scrivener) C++14
12 / 100
264 ms 48504 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<char> v[1000005];
const int lg=4;
int Len[1000005],pa[1000005],up[lg+1][1000005],ti[1000005],t;

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

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

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

char GetLetter(int P)
{
	int x=pa[ti[t]];
	for(int i=lg;i>=0;--i)
		if(Len[up[i][x]]>P)
			x=up[i][x];
	if(Len[x]>P)
		x=up[0][x];
	return v[x][P-Len[x]];
}

Compilation message

scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:29:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(v[pa[prev]].size()==Len[t]-Len[pa[prev]])
     ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 23936 KB Output is correct
2 Correct 22 ms 23928 KB Output is correct
3 Correct 23 ms 23936 KB Output is correct
4 Correct 23 ms 23936 KB Output is correct
5 Correct 23 ms 23932 KB Output is correct
6 Correct 21 ms 23936 KB Output is correct
7 Correct 22 ms 23936 KB Output is correct
8 Correct 22 ms 23936 KB Output is correct
9 Correct 23 ms 23808 KB Output is correct
10 Correct 22 ms 23884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 23808 KB Output is correct
2 Correct 21 ms 23808 KB Output is correct
3 Correct 22 ms 23936 KB Output is correct
4 Correct 24 ms 23936 KB Output is correct
5 Correct 22 ms 23808 KB Output is correct
6 Correct 21 ms 23936 KB Output is correct
7 Correct 22 ms 23936 KB Output is correct
8 Correct 22 ms 23928 KB Output is correct
9 Correct 22 ms 23936 KB Output is correct
10 Correct 22 ms 23808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 23936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 186 ms 48504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 264 ms 46916 KB Output isn't correct
2 Halted 0 ms 0 KB -