답안 #237318

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
237318 2020-06-05T22:09:44 Z limabeans 가로등 (APIO19_street_lamps) C++17
20 / 100
5000 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;






bool get(int l, int r, vector<int> a) {
    for (int i=l; i<r; i++) {
	if (!a[i]) return false;
    }
    return true;
}


int n, q;
vector<int> a[maxn];



int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n>>q;
    string s; cin>>s;
    a[0].resize(n+1);
    for (int i=1; i<=n; i++) {
	a[0][i]=(s[i-1]-'0');
    }

    a[1]=a[0];


    for (int qq=1; qq<=q; qq++) {
	string op; cin>>op;
	a[qq+1]=a[qq];
	if (op=="query") {
	    int res=0;
	    int l,r; cin>>l>>r;
	    for (int t=1; t<=qq; t++) {
		res += get(l,r,a[t]);
	    }
	    cout<<res<<"\n";
	} else {
	    //toggle
	    int i; cin>>i;
	    a[qq+1][i]=1-a[qq+1][i];
	}
    }


    // for (int t=0; t<=q; t++) {
    // 	for (int i=1; i<=n; i++) {
    // 	    cout<<a[t][i];
    // 	}
    // 	cout<<endl;
    // }
  

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 23808 KB Output is correct
2 Correct 18 ms 23808 KB Output is correct
3 Correct 19 ms 23936 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Correct 18 ms 23808 KB Output is correct
6 Correct 19 ms 23808 KB Output is correct
7 Correct 19 ms 23808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5065 ms 32252 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 27776 KB Output is correct
2 Correct 69 ms 27772 KB Output is correct
3 Correct 114 ms 27768 KB Output is correct
4 Correct 256 ms 27772 KB Output is correct
5 Runtime error 372 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 178 ms 27896 KB Output is correct
2 Correct 165 ms 27836 KB Output is correct
3 Correct 116 ms 27768 KB Output is correct
4 Correct 28 ms 27776 KB Output is correct
5 Runtime error 255 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 23808 KB Output is correct
2 Correct 18 ms 23808 KB Output is correct
3 Correct 19 ms 23936 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Correct 18 ms 23808 KB Output is correct
6 Correct 19 ms 23808 KB Output is correct
7 Correct 19 ms 23808 KB Output is correct
8 Execution timed out 5065 ms 32252 KB Time limit exceeded
9 Halted 0 ms 0 KB -