# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
739152 | 2023-05-10T04:14:16 Z | nguyentunglam | 가로등 (APIO19_street_lamps) | C++17 | 61 ms | 1324 KB |
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; const int N = 110; int a[N]; int f[N][N]; int main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen ("task.inp", "r")) { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); } if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int n, q; cin >> n >> q; string s; cin >> s; s = " " + s; for(int i = 1; i <= n; i++) a[i] = s[i] - '0'; for(int timer = 1; timer <= q; timer++) { string ask; cin >> ask; if (ask[0] == 't') { int i; cin >> i; int l = i - 1, r = i + 1; a[i] ^= 1; while (a[l]) l--; while (a[r]) r++; l++; r--; // cout << l << " " << r << endl; for(int j = l; j <= i; j++) for(int k = i; k <= r; k++) { if (a[i]) f[j][k] -= timer; else f[j][k] += timer; } } else { int l, r; cin >> l >> r; r--; bool ok = 1; for(int j = l; j <= r; j++) ok &= a[j]; int ans = f[l][r]; if (ok) ans += timer; cout << ans << endl; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 324 KB | Output is correct |
4 | Correct | 1 ms | 328 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 61 ms | 1324 KB | Output is correct |
2 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 324 KB | Output is correct |
4 | Correct | 1 ms | 328 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 61 ms | 1324 KB | Output is correct |
9 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
10 | Halted | 0 ms | 0 KB | - |