Submission #743832

# Submission time Handle Problem Language Result Execution time Memory
743832 2023-05-18T04:17:01 Z ThMinh_ Street Lamps (APIO19_street_lamps) C++14
20 / 100
259 ms 4408 KB
#include<bits/stdc++.h>
#define forin(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
const int N = 1e2 + 10;
int n, q;
int a[N];
int tr[N][N];
int main () {
    cin.tie(0)->sync_with_stdio(0);
    if(fopen("Task.inp","r")) {
        freopen("Task.inp","r",stdin);
        freopen("AC.out","w",stdout);
    }
    cin>>n>>q;
    string s; cin>>s;
    s = " " + s;
    forin(i,1,n) a[i] = (s[i] == '1');
    while(q--) {
        forin(i,1,n + 1) forin(j,i + 1,n + 1) {
            bool ok = 1;
            forin(k,i,j - 1) ok &= a[k];
            if(!ok) break;
            tr[i][j]++;
        }
        string s; cin>>s;
        if(s[0] == 't') {
            int i; cin>>i;
            a[i] = 1 - a[i];
        }
        else {
            int a, b; cin>>a>>b;
            cout<<tr[a][b]<<"\n";
        }
    }
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:11:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         freopen("Task.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen("AC.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 12 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 259 ms 4408 KB Output is correct
2 Runtime error 1 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 12 ms 340 KB Output is correct
8 Correct 259 ms 4408 KB Output is correct
9 Runtime error 1 ms 596 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -