Submission #1232984

#TimeUsernameProblemLanguageResultExecution timeMemory
1232984kaltspielerhyCrayfish scrivener (IOI12_scrivener)C++20
34 / 100
1094 ms2480 KiB
#include <bits/stdc++.h>
using namespace std;

vector<pair<int, char>> commandes;
vector<int> activate;

void Init() {}

void TypeLetter(char L) {
    commandes.push_back({0, L});
	activate.push_back(1);
}

void UndoCommands(int U) {
	int undo = 1;
	int valeur = commandes.size()-1;
	priority_queue<int, vector<int>, greater<int>> file;
	file.push(U);
	int cpt = 0;
	while (!file.empty()) {
		int obj = file.top();
		file.pop();

		obj -= cpt;

		if (obj <= 0) {
			undo = (undo+1)%2;
			// cerr << undo << '\n';
			continue;
		}
		cpt++;
		
		if (undo == 1) {
			if (commandes[valeur].first != 0) {
				undo = (undo+1)%2;
				file.push(commandes[valeur].first+cpt);
				activate[valeur] = (activate[valeur]+1)%2;
			}
			else {
				activate[valeur] = (activate[valeur]+1)%2;
				// cerr << "mod" << activate[valeur] << '\n';
			}
		}

		valeur--;

		file.push(obj+cpt-1);
	}

	commandes.push_back({U, '!'});
	activate.push_back(1);
	// for (int i : activate) cerr << i << ' ';
	// cerr << '\n';
}

char GetLetter(int P) {
	int compteur = 0;
	for (int i = 0; i < commandes.size(); i++) {
		if (activate[i] && commandes[i].first == 0) {
			if (compteur == P) return commandes[i].second;
			compteur++;
		}
	}
}

Compilation message (stderr)

scrivener.cpp: In function 'char GetLetter(int)':
scrivener.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
   64 | }
      | ^
#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...