제출 #527046

#제출 시각아이디문제언어결과실행 시간메모리
527046Lobo가로등 (APIO19_street_lamps)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

#define maxn 330000

int n, q;
int s1[110][110];
int s2[maxn], ans2[maxn], cur2[maxn];

void solve() {
    string est;
    cin >> n >> q >> est;

    for(int i = 1; i <= q; i++) {
        string sss; cin >> sss;
        if(sss == "toggle") {
            int pos; cin >> pos;
            qr[i] = mp(sss,mp(pos,0));
        }
        else {
            int l, r;
            cin >> l >> r;
            qr[i] = mp(sss,mp(l,r));
        }

    }

    if(n <= 100 && q <= 100) {
        for(int i = 1; i <= n; i++) {
            s1[i][0] = est[i-1]-'0';
        }

        for(int i = 1; i <= q; i++) {
            for(int j = 1; j <= n; j++) {
                s1[j][i] = s1[j][i-1];
            }

            string sss; sss = qr[i].fr;
            if(sss == "toggle") {
                int pos; pos = qr[i].sc.fr;
                s1[pos][i]^= 1;
                continue;
            }

            int l,r; cin >> l >> r;
            r--;
            int ans = 0;
            for(int j = 0; j < i; j++) {
                int ok = 1;
                for(int k = l; k <= r; k++) {
                    if(s1[k][j] == 0) ok = 0;
                }
                ans+= ok;
            }

            cout << ans << endl;
        }
    }
    else {
        for(int i = 1; i <= n; i++) {
            s2[i] = est[i-1]-'0';
            cur2[i] = 0;
            ans2[i] = 0;
        }

        for(int i = 1; i <= q; i++) {
            string sss; sss = qr[i].fr;
            int pos; pos = qr[i].sc.fr;
            ans2[pos]+= (i-cur2[pos])*s2[pos];
            cur2[pos] = i;

            if(sss == "toggle") {
                ans2[pos]+= (i-cur2[pos])*s2[pos];
                cur2[pos] = i;
                s2[pos]^= 1;
                continue;
            }

            pos = qr[i].sc.sc; pos--;

            cout << ans2[pos] << endl;
        }
    }


}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);

    // freopen("in.in", "r", stdin);
    //freopen("out.out", "w", stdout);

    int tt = 1;
    // cin >> tt;
    while(tt--) solve();

}

컴파일 시 표준 에러 (stderr) 메시지

street_lamps.cpp: In function 'void solve()':
street_lamps.cpp:29:13: error: 'qr' was not declared in this scope; did you mean 'q'?
   29 |             qr[i] = mp(sss,mp(pos,0));
      |             ^~
      |             q
street_lamps.cpp:34:13: error: 'qr' was not declared in this scope; did you mean 'r'?
   34 |             qr[i] = mp(sss,mp(l,r));
      |             ^~
      |             r
street_lamps.cpp:49:31: error: 'qr' was not declared in this scope; did you mean 'q'?
   49 |             string sss; sss = qr[i].fr;
      |                               ^~
      |                               q
street_lamps.cpp:78:31: error: 'qr' was not declared in this scope; did you mean 'q'?
   78 |             string sss; sss = qr[i].fr;
      |                               ^~
      |                               q