이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//debug icin gdb kullanmayi dene
#include<bits/stdc++.h>
using namespace std;
#define mods 1000000007
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define rs resize
#define pii pair<lint,lint>
#define piii pair<lint,pair<lint,lint> >
#define inf LLONG_MAX-7
#define vvL vector<vector<lint> >
#define vvB vector<vector<bool> >
#define vvvL vector<vector<vector<lint> > >
#define vL vector<lint>
#define vpii vector<pii>
#define vB vector<bool>
typedef long long int lint;
typedef unsigned long long int ulint;
lint fastpow(lint tab,lint us){
if(tab==0) return 0;
if(tab==1) return 1;
if(us==0) return 1;
if(us==1) return tab%mods;
tab%=mods;
if(us%2==1) return tab*fastpow(tab,us-1)%mods;
lint a=fastpow(tab,us/2)%mods;
return a*a%mods;
}
lint t=1,n,q;
string s;
vL cez,mev;
void solve(){
lint i,j,a,b,k;
cin>>n>>q;
cin>>s;
cez.rs(n+5,0);
mev.rs(n+5,-1);
string str;
for(i=1;i<=n;i++) if(s[i-1]=='0') mev[i]=0;
for(j=1;j<=q;j++){
cin>>str;
if(str=="query"){
cin>>a>>b;
if(mev[a]==-1) cout<<j-cez[a]<<endl;
else cout<<mev[a]-cez[a]<<endl;
}else{
cin>>a;
if(mev[a]!=-1){
cez[a]+=j-mev[a];
mev[a]=-1;
}else{
mev[a]=j;
}
}
}
return;
}
int main(){
// freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// cin>>t;
while(t--) solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
street_lamps.cpp: In function 'void solve()':
street_lamps.cpp:35:15: warning: unused variable 'k' [-Wunused-variable]
35 | lint i,j,a,b,k;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |