답안 #403171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403171 2021-05-12T21:36:39 Z AmineTrabelsi 가로등 (APIO19_street_lamps) C++14
20 / 100
5000 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;
// Hi

int main(){
    //ios::sync_with_stdio(0);cin.tie(0);
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    vector<vector<int>> cnt(n+2,vector<int>(n+1,0));
    vector<int> pref(n+2,0);
    for(int i=0;i<=n;i++){
        pref[i+1] = pref[i]+(s[i]=='1');
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<i;j++){
            cnt[i][j] = cnt[j][i] = (pref[i]-pref[j] == i-j);
            //cout << j<<" "<<i<<" "<<cnt[i][j]<<'\n';
        }
    }
    for(int tt=1;tt<=q;tt++){
        string t;
        cin>>t;
        if(t == "toggle"){
            int ind;
            cin>>ind;
            ind--;
            if(s[ind] == '0')s[ind] = '1';
            else s[ind] = '0';
            for(int i=0;i<n;i++){
                pref[i+1] = pref[i]+(s[i]=='1');
            }
        }else{
            int a,b;
            cin>>a>>b;
            a--,b--;
            cout << cnt[a][b] << '\n';
        }
        for(int i=0;i<=n;i++){
            for(int j=0;j<i;j++){
                cnt[i][j] = cnt[j][i] += (pref[i]-pref[j] == i-j);
            }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5060 ms 4408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1842 ms 4244 KB Output is correct
2 Correct 1814 ms 4164 KB Output is correct
3 Correct 1925 ms 4172 KB Output is correct
4 Correct 1983 ms 4172 KB Output is correct
5 Runtime error 266 ms 524292 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1978 ms 4172 KB Output is correct
2 Correct 1904 ms 4248 KB Output is correct
3 Correct 1840 ms 4252 KB Output is correct
4 Correct 1860 ms 4248 KB Output is correct
5 Runtime error 276 ms 524292 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Execution timed out 5060 ms 4408 KB Time limit exceeded
9 Halted 0 ms 0 KB -