제출 #867069

#제출 시각아이디문제언어결과실행 시간메모리
867069Huseyn123크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
5 / 100
97 ms168252 KiB
#include <bits/stdc++.h> #define MAX 1000010 #define INF INT_MAX #define MOD 1000000007 #define mp make_pair #define mt make_tuple #define pb push_back #define ins insert #define ff first #define ss second #define gett(x,m) get<m>(x) #define all(a) a.begin(),a.end() #define lb(a,b) lower_bound(all(a),b) #define ub(a,b) upper_bound(all(a),b) #define sortv(a) sort(all(a)) #define sorta(a,sz) sort(a,a+sz) #define inputar(a,b){\ for(int i=0;i<b;i++){\ cin >> a[i];\ }\ } #define inputvec(a,b){\ for(int i=0;i<b;i++){\ ll num;\ cin >> num;\ a.pb(num);\ }\ } #define outputar(a,b){\ for(int i=0;i<b;i++){\ cout << a[i] << " ";\ }\ cout << "\n";\ } #define outputvec(a){\ for(auto x:a){\ cout << x << " ";\ }\ cout << "\n";\ } #define reset(a,n,v){\ for(int i=0;i<n;i++){\ a[i]=v;\ }\ } using namespace std; typedef long long ll; typedef unsigned long long ull; typedef tuple<ll,ll,ll> tll; typedef pair<ll,ll> pll; typedef pair<int,int> pii; typedef double db; typedef long double ldb; inline void USACO(string filename){ freopen((filename+".in").c_str(),"r",stdin); freopen((filename+".out").c_str(),"w",stdout); } int cnt=1; int lastU=0; int a[MAX],b[MAX],e[MAX]; vector<vector<int>> c; vector<int> d; vector<char> d1; void Init() { c.resize(21,vector<int>(MAX,INF)); d.pb(0); d1.pb('0'); } void TypeLetter(char L) { d1.pb(L); a[cnt]=a[cnt-1]+1; cnt++; } void UndoCommands(int U) { d1.pb('0'); auto it=lb(d,max(cnt-U,1)); --it; c[0][cnt]=*it; int h=*it; for(int i=1;i<=20;i++){ if(h!=INF){ h=c[i-1][h]; } c[i][cnt]=h; } d.pb(cnt); a[cnt]=a[cnt-1]; b[cnt]=a[max(cnt-U-1,0)]-a[*it]+b[*it]; e[cnt]=U; lastU=cnt; cnt++; } char GetLetter(int P) { a[cnt]=a[cnt-1]; b[cnt]=a[cnt]-a[lastU]+b[lastU]; e[cnt]=0; P+=1; int h=lastU; for(int i=20;i>=0;i--){ if(c[i][h]!=INF && b[c[i][h]]>=P){ h=c[i][h]; } } if(b[h]<P){ h=cnt; } return d1[h-e[h]-1-(b[h]-P)]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...