제출 #1233754

#제출 시각아이디문제언어결과실행 시간메모리
1233754Zbyszek99크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++20
34 / 100
354 ms327680 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define ld long double #define ull unsigned long long #define ff first #define ss second #define pii pair<int,int> #define pll pair<long long, long long> #define vi vector<int> #define vl vector<long long> #define pb push_back #define rep(i, b) for(int i = 0; i < (b); ++i) #define rep2(i,a,b) for(int i = a; i <= (b); ++i) #define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c) #define count_bits(x) __builtin_popcountll((x)) #define all(x) (x).begin(),(x).end() #define siz(x) (int)(x).size() #define forall(it,x) for(auto& it:(x)) using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; //mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());} //ll los(ll a, ll b) {return a + (mt() % (b-a+1));} const int INF = 1e9+50; const ll INF_L = 1e18+40; const ll MOD = 1e9+7; struct node { int l = 0; int r = (1 << 20)-1; node* left; node* right; bool is_son = 0; char val = 'a'; void get_son() { if(!is_son) { left = new node; left -> l = l; left -> r = (l+r)/2; right = new node; right -> l = (l+r)/2+1; right -> r = r; } is_son = 1; } char get_val(int poz) { if(l == r) return val; if((l+r)/2 >= poz) return left -> get_val(poz); return right -> get_val(poz); } void add(int poz, node* prev, int x) { if(l == r) { val = x; return; } prev -> get_son(); is_son = 1; if(poz <= (l+r)/2) { right = prev -> right; left = new node; left -> l = l; left -> r = (l+r)/2; left -> add(poz,prev->left,x); } else { left = prev -> left; right = new node; right -> l = (l+r)/2+1; right -> r = r; right -> add(poz,prev->right,x); } } }; vector<node*> nodes; vi sizes; void Init() { node* xd = new node; nodes.pb(xd); sizes.pb(0); } void TypeLetter(char L) { node* xd2 = new node; xd2->add(sizes.back(),nodes[siz(nodes)-1],L); sizes.pb(sizes.back()+1); nodes.emplace_back(xd2); } void UndoCommands(int U) { nodes.pb(nodes[siz(nodes)-1-U]); sizes.pb(sizes[siz(sizes)-1-U]); } char GetLetter(int P) { return nodes.back() -> get_val(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...