# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
267100 | 2020-08-15T20:03:35 Z | kimbj0709 | 가로등 (APIO19_street_lamps) | C++14 | 2 ms | 640 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define maxn 105 int32_t main(){ ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n,q; cin >> n >> q; string input; cin >> input; vector<int> currpos(maxn,0); for(int i=0;i<input.length();i++){ if(input.at(i)=='1'){ currpos[i+1] = 1; } } int arr[maxn][maxn]; for(int i=1;i<=n;i++){ arr[0][i] = currpos[i]; arr[0][i] += arr[0][i-1]; //cout << arr[0][i] << " "; } //cout << endl; string input1; int input2,input3; for(int i=1;i<=q;i++){ cin >> input1; if(input1=="toggle"){ cin >> input2; if(currpos[input2]==1){ currpos[input2] = 0; } else{ currpos[input2] = 1; } for(int j=1;j<=n;j++){ arr[i][j] = currpos[j]; arr[i][j] += arr[i][j-1]; } } else{ cin >> input2 >> input3; input3--; int ans = 0; for(int j=0;j<i;j++){ ans += (arr[j][input3]-arr[j][input2-1]==input3-input2+1); } for(int j=1;j<=n;j++){ arr[i][j] = currpos[j]; arr[i][j] += arr[i][j-1]; } cout << ans << "\n"; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 640 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 640 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 640 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Runtime error | 1 ms | 640 KB | Execution killed with signal 11 |
9 | Halted | 0 ms | 0 KB | - |