Submission #743832

#TimeUsernameProblemLanguageResultExecution timeMemory
743832ThMinh_Street Lamps (APIO19_street_lamps)C++14
20 / 100
259 ms4408 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...