Submission #404953

#TimeUsernameProblemLanguageResultExecution timeMemory
404953A_DStreet Lamps (APIO19_street_lamps)C++14
0 / 100
476 ms3636 KiB
#include <bits/stdc++.h> #define int long long #define ii pair<int,int> #define F first #define S second #define du long double using namespace std; const int N=3e5+100; int a[N]; int ans[N]; void solve() { int n,q; cin>>n>>q; string s; cin>>s; int cnt=0; for(auto x:s){ cnt++; if(x=='1'){ a[cnt]=0; } else{ a[cnt]=-1; } } for(int i=1;i<=q;i++){ string s; cin>>s; if(s=="query"){ int b; scanf("%lld",&b); scanf("%lld",&b); b--; int u=ans[b]; if(a[b]!=-1){ u+=i-a[b]; } printf("%lld\n",u); } else{ int b; scanf("%lld",&b); if(a[b]==-1){ a[b]=i; } else{ ans[i]+=i-a[b]; a[b]=-1; } } } } main() { int t=1; //cin>>t; while(t--)solve(); }

Compilation message (stderr)

street_lamps.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main()
      | ^~~~
street_lamps.cpp: In function 'void solve()':
street_lamps.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |             scanf("%lld",&b);
      |             ~~~~~^~~~~~~~~~~
street_lamps.cpp:33:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |             scanf("%lld",&b);
      |             ~~~~~^~~~~~~~~~~
street_lamps.cpp:43:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |             scanf("%lld",&b);
      |             ~~~~~^~~~~~~~~~~
#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...