답안 #404960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
404960 2021-05-15T12:05:24 Z A_D 가로등 (APIO19_street_lamps) C++14
20 / 100
4 ms 588 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=1e2+10;
int a[N][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]=1;
        }
        else{
            a[cnt][0]=0;
        }
    }
    for(int i=1;i<=q;i++){
        for(int j=1;j<=n;j++){
            a[j][i]=a[j][i-1];
        }
        string s;
        cin>>s;
        if(s=="query"||s=="1"){
            int u,v,ans=0;
            cin>>u>>v;
            for(int t=0;t<i;t++){
                int bo=1;
                for(int j=u;j<v;j++){
                    bo&=a[j][t];
                }
                ans+=bo;
              //  cout<<bo<<" ";
            }
            //cout<<"\n";
            cout<<ans<<endl;
        }
        else{
            int b;
            scanf("%lld",&b);
            a[b][i]^=1;
        }
    }
}

main()
{
    int t=1;
    //cin>>t;
    while(t--)solve();
}






Compilation message

street_lamps.cpp:54:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   54 | main()
      | ^~~~
street_lamps.cpp: In function 'void solve()':
street_lamps.cpp:48:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |             scanf("%lld",&b);
      |             ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Runtime error 4 ms 588 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -