Submission #432841

#TimeUsernameProblemLanguageResultExecution timeMemory
432841TLP39가로등 (APIO19_street_lamps)C++14
20 / 100
151 ms3864 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> pll; int n,q; bool on[300010]; int last_open[300010]={}; char s[300010]; int res[300010]={}; int l,r; int ans; int main() { scanf("%d %d",&n,&q); scanf("%s",s); for(int i=0;i<n;i++) on[i+1]=(s[i]=='1'); for(int i=1;i<=q;i++) { scanf("%s",s); if(s[0]=='q') { scanf("%d %d",&l,&r); if(on[l]) printf("%d\n",res[l]+(i-last_open[l])); else printf("%d\n",res[l]); } else { scanf("%d",&l); if(on[l]) { on[l]=false; res[l]+=(i-last_open[l]); } else { on[l]=true; last_open[l]=i; } } } }

Compilation message (stderr)

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d %d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~~
street_lamps.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%s",s);
      |     ~~~~~^~~~~~~~
street_lamps.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf("%s",s);
      |         ~~~~~^~~~~~~~
street_lamps.cpp:23:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |             scanf("%d %d",&l,&r);
      |             ~~~~~^~~~~~~~~~~~~~~
street_lamps.cpp:29:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |             scanf("%d",&l);
      |             ~~~~~^~~~~~~~~
#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...