Submission #337139

# Submission time Handle Problem Language Result Execution time Memory
337139 2020-12-18T15:34:25 Z Fidisk Street Lamps (APIO19_street_lamps) C++14
0 / 100
3 ms 492 KB
#include <bits/stdc++.h>
using namespace std;

#define oo 1e12
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;

const ll mod=1e9+7;

string s[5009],t;
ll n,q,i,res,l,r,j,k;
bool ok;

int main(){
    IO;
    #ifndef ONLINE_JUDGE
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    #else
    #endif
    cin>>n>>q;

    cin>>s[1];
    s[1]=" "+s[1];
    for (i=1;i<=q;i++) {
        cin>>t;
        s[i+1]=s[i];
        if (t=="query") {
            cin>>l>>r;
            for (j=1;j<=i;j++) {
                ok=true;
                for (k=l;k<=r;k++) {
                    if (s[j][k]=='0') {
                        ok=false;
                        break;
                    }
                }
                if (ok) {
                    //cout<<l<<' '<<r<<' '<<s[i]<<' '<<i<<'\n';
                    res++;
                }
            }
            cout<<res<<'\n';
                res=0;
        }
        else {
            cin>>j;
            if (s[i+1][j]=='0') {
                s[i+1][j]='1';
            }
            else {
                s[i+1][j]='0';
            }
        }
    }
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   30 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:31:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   31 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -