Submission #211235

#TimeUsernameProblemLanguageResultExecution timeMemory
211235mode149256Crayfish scrivener (IOI12_scrivener)C++14
100 / 100
810 ms125552 KiB
/*input

*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


char last;
vii jump;
vi sz;
vector<char> kas;

const int LG = 20;

void Init() {

}

void TypeLetter(char L) {
	if (jump.empty()) {
		jump.push_back(vi(LG, 0));
		sz.push_back(1);
		kas.push_back(L);
		return;
	}

	jump.push_back(vi(LG));
	sz.push_back(sz.back() + 1);
	kas.push_back(L);

	int c = sz.size() - 1;

	jump[c][0] = c - 1;
	for (int i = 1; i < LG; ++i)
		jump[c][i] = jump[jump[c][i - 1]][i - 1];
	last = L;
}

void UndoCommands(int U) {
	int k = sz.size() - 1 - U;
	sz.push_back(sz[k]);
	jump.push_back(jump[k]);
	kas.push_back(kas[k]);
}

char GetLetter(int P) {
	int k = sz.back() - P - 1;

	int c = (int)sz.size() - 1;

	for (int i = 0; i < LG; ++i)
	{
		if ((k >> i) & 1)
			c = jump[c][i];
	}

	return kas[c];
	// assert(buvo.size());
	// return gauk(buvo.back(), 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...