Submission #759614

#TimeUsernameProblemLanguageResultExecution timeMemory
759614aykhnCrayfish scrivener (IOI12_scrivener)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
 
// author: aykhn

using namespace std;

#define mpr make_pair
#define pb push_back
#define fi first
#define se second

string s;
vector<pair<int, char>> calls;

void Init() 
{
    s = "";
}

void TypeLetter(char L) 
{
    calls.pb(mpr(1, L));
}

void UndoCommands(int U) 
{
    calls.pb(mpr(2, U));
}

char GetLetter(int P) 
{
    if (x == 1)
    {
        int i = calls.size() - 1;
        
        while (i >= 0)
        {
            if (calls[i].fi == 2)
            {
                calls[i].fi = 0;
                for (int k = 1; k <= calls[i].se; k++)
                {
                    i--;
                    if (i >= 0) calls[i].fi = 0; 
                }
            }
            i--;
        }
        
        for (int i = 0; i < calls.size(); i++)
        {
            if (calls[i].fi == 1)
            {
                s.pb(calls[i].se);
            }                
        }
    }
    
    return s[P];
}

Compilation message (stderr)

scrivener.cpp: In function 'char GetLetter(int)':
scrivener.cpp:32:9: error: 'x' was not declared in this scope
   32 |     if (x == 1)
      |         ^
scrivener.cpp:50:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for (int i = 0; i < calls.size(); i++)
      |                         ~~^~~~~~~~~~~~~~