Submission #1367072

#TimeUsernameProblemLanguageResultExecution timeMemory
1367072Nxmkxingcmp (balkan11_cmp)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 110;
int n, q;
string s;
int total[N], start[N];

int main() {
    cin.tie(nullptr)->ios_base::sync_with_stdio(false);
    cin >> n >> q >> s;
    for (int i = 1; i <= n; i++) {
        if (s[i-1] == '0') start[i] = -1;
        else start[i] = 0;
    }
    for (int i = 1; i <= q; i++) {
        string type;
        cin >> type;
        if (type == "toggle") {
            int pos;
            cin >> pos;
            if (start[pos] == -1) start[pos] = i;
            else {
                total[pos] += i - start[pos];
                start[pos] = -1;
            }
        } 
        else {
            int a, b;
            cin >> a >> b;
            if (start[a] == -1) cout << total[a] << "\n";
            else cout << total[a] + i - start[a] << "\n";
        }
    }
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cc87w8fc.o: in function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'; /tmp/cc6V1jF1.o:cmp.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc87w8fc.o: in function `main':
grader.c:(.text.startup+0x33): undefined reference to `remember(int)'
/usr/bin/ld: grader.c:(.text.startup+0x143): undefined reference to `compare(int)'
collect2: error: ld returned 1 exit status