Submission #404113

# Submission time Handle Problem Language Result Execution time Memory
404113 2021-05-13T19:27:46 Z Hazem Street Lamps (APIO19_street_lamps) C++14
20 / 100
710 ms 8836 KB
#include <bits/stdc++.h>
using namespace std;
 
#define LL long long
#define F first
#define S second
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>

const int N = 3e5+10;
const int M = 200;
const LL INF = 1e9;
const LL LINF = 2e18;
const LL MOD = 1e9+7;
const double PI = 3.141592653589793;

int ans[N],last[N];

int main(){

    //freopen("out.txt","w",stdout);

    int n,q;
    scanf("%d%d",&n,&q);
    string s;cin>>s;
    
    for(int i=0;i<n;i++)
        if(s[i]=='0')
            last[i] = -1;

    for(int t = 1;t<=q;t++){
        string s1;cin>>s1;
        if(s1[0]=='q'){
            int l,r;
            scanf("%d%d",&l,&r);
            l--,r--;
            printf("%d\n",ans[l]+(last[l]==-1?0:t-last[l]));
        }
        else {
            int x;scanf("%d",&x);x--;

            if(s[x]=='0')
                s[x] = '1',last[x] = t;
            else 
                ans[x] += t-last[x],last[x] = -1,s[x] = '0';
        }
    }
}   

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d%d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~
street_lamps.cpp:35:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |             scanf("%d%d",&l,&r);
      |             ~~~~~^~~~~~~~~~~~~~
street_lamps.cpp:40:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |             int x;scanf("%d",&x);x--;
      |                   ~~~~~^~~~~~~~~
# 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 Correct 392 ms 1212 KB Output is correct
2 Correct 392 ms 4612 KB Output is correct
3 Correct 399 ms 5324 KB Output is correct
4 Correct 430 ms 8836 KB Output is correct
5 Correct 475 ms 8088 KB Output is correct
6 Correct 383 ms 8656 KB Output is correct
7 Correct 691 ms 8552 KB Output is correct
8 Correct 710 ms 8604 KB Output is correct
# 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 3 ms 204 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 -