답안 #211446

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
211446 2020-03-20T11:08:58 Z VEGAnn 가로등 (APIO19_street_lamps) C++14
20 / 100
135 ms 12364 KB
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define pll pair<ll, ll>
#define MP make_pair
#define PB push_back
#define pii pair<int, int>
#define pi3 pair<pii, int>
#define ft first
#define sd second
#define MP3(a,b,c) MP(MP(a,b),c)
using namespace std;
typedef long long ll;
const int N = 300100;
const int M = 100100;
const int Q = 100100;
const int CO = 200100;
const int oo = 2e9;
const int B = 1;
const int MB = M / B + 10;
string s, qr;
int n, q, tp[N], lst[N], sum[N];

int main(){

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#else
    ios_base::sync_with_stdio(0); cin.tie(0);
#endif // _LOCAL

    cin >> n >> q >> s;

    for (int i = 0; i < n; i++){
        sum[i] = 0;
        tp[i] = s[i] - '0';
        lst[i] = 0;
    }

    for (int i = 1; i <= q; i++){
        cin >> qr;

        if (qr[0] == 't'){
            int x; cin >> x;
            x--;

            if (tp[x] == 1)
                sum[x] += i - lst[x];

            tp[x] ^= 1;
            lst[x] = i;
        } else {
            int a, b; cin >> a >> b;
            a--; b--;

            int ans = sum[a];

            if (tp[a] == 1)
                ans += i - lst[a];

            cout << ans << '\n';
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 1400 KB Output is correct
2 Correct 86 ms 1272 KB Output is correct
3 Correct 84 ms 1528 KB Output is correct
4 Correct 106 ms 9612 KB Output is correct
5 Correct 112 ms 10636 KB Output is correct
6 Correct 104 ms 9868 KB Output is correct
7 Correct 127 ms 10892 KB Output is correct
8 Correct 135 ms 12364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -