답안 #1005018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005018 2024-06-22T06:14:28 Z vjudge1 가로등 (APIO19_street_lamps) C++17
20 / 100
5000 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	int pre[n+1],ans[n][n+1]={};
	pre[0]=0;
	for (int i=0;i<n;i++)
		pre[i+1]=pre[i]+(s[i]-'0');
	for (int i=0;i<n;i++)
		for (int j=i+1;j<=n;j++)
			ans[i][j]=(pre[j]-pre[i]==j-i);
	while (q--)
	{
		string t;
		cin>>t;
		if (t=="query")
		{
			int a,b;
			cin>>a>>b;
			cout<<ans[a-1][b-1]<<endl;
		}
		else
		{
			int i;
			cin>>i;
			s[i-1]=char('0'+1-(s[i-1]-'0'));
		}
		pre[0]=0;
		for (int i=0;i<n;i++)
			pre[i+1]=pre[i]+(s[i]-'0');
		for (int i=0;i<n;i++)
			for (int j=i+1;j<=n;j++)
				ans[i][j]+=(pre[j]-pre[i]==j-i);
	}
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1297 ms 1236 KB Output is correct
2 Execution timed out 5069 ms 1076 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 385 ms 4188 KB Output is correct
2 Correct 367 ms 4184 KB Output is correct
3 Correct 406 ms 4188 KB Output is correct
4 Correct 376 ms 4184 KB Output is correct
5 Runtime error 263 ms 524288 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 381 ms 4188 KB Output is correct
2 Correct 388 ms 4188 KB Output is correct
3 Correct 377 ms 4332 KB Output is correct
4 Correct 413 ms 4188 KB Output is correct
5 Runtime error 253 ms 524288 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1297 ms 1236 KB Output is correct
9 Execution timed out 5069 ms 1076 KB Time limit exceeded
10 Halted 0 ms 0 KB -