Submission #1044795

# Submission time Handle Problem Language Result Execution time Memory
1044795 2024-08-05T13:36:27 Z vjudge1 Street Lamps (APIO19_street_lamps) C++17
20 / 100
35 ms 7988 KB
#include "bits/stdc++.h"
using namespace std;

#define int int64_t    
#define pb push_back

using lint=__int128_t;

const int lim=200100;
const int mod=1e9+7;

using pii=pair<int,int>;

struct query{
    int t,x,y;
};

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifdef Local  
    freopen(".in","r",stdin);freopen(".out","w",stdout);
#endif
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    query q[m];
    for(int i=0;i<m;i++){
        string t;
        cin>>t;
        if(t=="toggle"){
            q[i].t=0;
        }else{
            q[i].t=1;
        }
        if(q[i].t){
            cin>>q[i].x>>q[i].y;
        }else{
            cin>>q[i].x;
        }
            q[i].x--,q[i].y--;
    }
    if(n<=100&&m<=100){
        int arr[m+1][n];
        for(int i=0;i<n;i++){
            arr[0][i]=s[i]-'0';
        }
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                arr[i+1][j]=arr[i][j];
                if(i&&!q[i-1].t&&q[i-1].x==j){
                    arr[i+1][j]=!arr[i+1][j];
                }
                //cerr<<arr[i+1][j]<<" ";
            }//cerr<<"\n";
            if(q[i].t){
                int cnt=0;
                //cerr<<q[i].x<<" "<<q[i].y<<"\n";
                for(int j=0;j<=i;j++){
                    bool ok=1;
                    for(int k=q[i].x;k<q[i].y;k++){
                        if(!arr[j+1][k]){
                            ok=0;
                            break;
                        }
                    }
                    cnt+=ok;
                }
                cout<<cnt<<"\n";
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 7988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 35 ms 7988 KB Output isn't correct
9 Halted 0 ms 0 KB -