Submission #404953

# Submission time Handle Problem Language Result Execution time Memory
404953 2021-05-15T11:36:47 Z A_D Street Lamps (APIO19_street_lamps) C++14
0 / 100
476 ms 3636 KB
#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

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 time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 476 ms 3636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -