제출 #404954

#제출 시각아이디문제언어결과실행 시간메모리
404954A_D가로등 (APIO19_street_lamps)C++14
20 / 100
745 ms11312 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++){ // for(int j=1;j<=n;j++)cout<<a[j]<<" ";cout<<endl; // for(int j=1;j<=n;j++)cout<<ans[j]<<" ";cout<<endl; string s; cin>>s; if(s=="query"||s=="1"){ 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[b]+=i-a[b]; a[b]=-1; } } } } main() { int t=1; //cin>>t; while(t--)solve(); }

컴파일 시 표준 에러 (stderr) 메시지

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