답안 #335106

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335106 2020-12-11T07:15:29 Z nicholask 가로등 (APIO19_street_lamps) C++14
40 / 100
1008 ms 11268 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,q;
	cin>>n>>q;
	string st;
	cin>>st;
	if (n<=100&&q<=100){
		vector <string> v;
		v.push_back(st);
		for (int z=1; z<=q; z++){
			string s;
			cin>>s;
			if (s=="toggle"){
				int u;
				cin>>u;
				u--;
				if (st[u]=='0') st[u]='1';
				else st[u]='0';
			} else {
				int t,u;
				cin>>t>>u;
				t--;
				u--;
				int cnt=0;
				for (auto&i:v){
					bool ok=1;
					for (int j=t; j<u; j++){
						if (i[j]!='1'){
							ok=0;
							break;
						}
					}
					if (ok) cnt++;
				}
				cout<<cnt<<endl;
			}
			v.push_back(st);
		}
	} else {
		int cnt[n]={},on[n]={};
		for (int i=0; i<n; i++){
			if (st[i]=='1') on[i]=0;
		}
		for (int z=1; z<=q; z++){
			string s;
			cin>>s;
			if (s=="toggle"){
				int u;
				cin>>u;
				u--;
				if (st[u]=='0'){
					st[u]='1';
					on[u]=z;
				} else {
					st[u]='0';
					cnt[u]+=z-on[u];
				}
			} else {
				int u,dummy;
				cin>>u>>dummy;
				u--;
				if (st[u]=='0') cout<<cnt[u]<<endl;
				else cout<<cnt[u]+z-on[u]<<endl;
			}
		}	
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 526 ms 4460 KB Output is correct
2 Correct 541 ms 4972 KB Output is correct
3 Correct 561 ms 5356 KB Output is correct
4 Correct 623 ms 9112 KB Output is correct
5 Correct 699 ms 9476 KB Output is correct
6 Correct 539 ms 8708 KB Output is correct
7 Correct 988 ms 9732 KB Output is correct
8 Correct 1008 ms 11268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 526 ms 4460 KB Output is correct
9 Correct 541 ms 4972 KB Output is correct
10 Correct 561 ms 5356 KB Output is correct
11 Correct 623 ms 9112 KB Output is correct
12 Correct 699 ms 9476 KB Output is correct
13 Correct 539 ms 8708 KB Output is correct
14 Correct 988 ms 9732 KB Output is correct
15 Correct 1008 ms 11268 KB Output is correct
16 Incorrect 1 ms 364 KB Output isn't correct
17 Halted 0 ms 0 KB -