Submission #254854

# Submission time Handle Problem Language Result Execution time Memory
254854 2020-07-30T18:06:00 Z Lawliet Street Lamps (APIO19_street_lamps) C++17
20 / 100
1033 ms 11164 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAXN = 300010;
 
int n, q;
 
int ans[MAXN];
int last[MAXN];

string s;
 
int main()
{
	cin >> n >> q;
	cin >> s;
 
	for(int i = 1 ; i <= q ; i++)
	{
		string type;
		cin >> type;
  
		if( type == "toggle" )
		{
			int ind;
			cin >> ind; ind--;

			if( s[ind] == '0' )
			{
				s[ind] = '1';
				last[ind] = i;
			}
			else
			{
				s[ind] = '0';
				ans[ind] += i - last[ind];
			}
		}
		if( type == "query" )
		{
			int l, r;
			cin >> l >> r; l--; r--;
  
			if( s[l] == '1' )
			{
				ans[l] += i - last[l];
				last[l] = i;
			}
 
			printf("%d\n",ans[l]);
		}
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 575 ms 4600 KB Output is correct
2 Correct 597 ms 4856 KB Output is correct
3 Correct 615 ms 5496 KB Output is correct
4 Correct 683 ms 8980 KB Output is correct
5 Correct 754 ms 9492 KB Output is correct
6 Correct 589 ms 8848 KB Output is correct
7 Correct 1020 ms 7516 KB Output is correct
8 Correct 1033 ms 11164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -