Submission #209216

# Submission time Handle Problem Language Result Execution time Memory
209216 2020-03-13T12:34:51 Z mieszko11b Street Lamps (APIO19_street_lamps) C++14
40 / 100
181 ms 3832 KB
#include <bits/stdc++.h>

using namespace std;

int n, q;
char c[107][107];
int before[300007], last0[300007];
char cc[300007];

int main() {
	scanf("%d%d", &n, &q);
	if(n <= 100 && q <= 100) {
		scanf(" %s", c[0] + 1);
		for(int i = 1 ; i <= q ; i++) {
			char comm[10];
			
			for(int j = 1 ; j <= n ; j++)	
				c[i][j] = c[i - 1][j];
			
			scanf(" %s", comm);
			if(comm[0] == 'q') {
				int a, b;
				scanf("%d%d", &a, &b);
				int res = 0;
				for(int j = 0 ; j < i ; j++) {
					bool ok = true;
					for(int k = a ; k < b ; k++)
						if(c[j][k] == '0')
							ok = false;
					if(ok) res++;
				}
				printf("%d\n", res);
			} else {
				int w;
				scanf("%d", &w);
				
				if(c[i][w] == '0') c[i][w] = '1';
				else c[i][w] = '0';
			}
		}
		return 0;
	}
	
	scanf(" %s", cc + 1);
	memset(last0, -1, sizeof last0);
	
	for(int i = 1 ; i <= q ; i++) {
		char comm[10];
		scanf(" %s", comm);
		if(comm[0] == 'q') {
			int a, b;
			scanf("%d%d", &a, &b);
			int res = before[a];
			if(cc[a] == '1')
				res += i - last0[a] - 1;
			printf("%d\n", res);
		} else {
			int w;
			scanf("%d", &w);
			if(cc[w] == '1') {
				before[w] += i - last0[w] - 1;
				cc[w] = '0';
			} else {
				last0[w] = i - 1;
				cc[w] = '1';
			}
		}
	}
	
	return 0;
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &q);
  ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %s", c[0] + 1);
   ~~~~~^~~~~~~~~~~~~~~~~
street_lamps.cpp:20:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf(" %s", comm);
    ~~~~~^~~~~~~~~~~~~
street_lamps.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &w);
     ~~~~~^~~~~~~~~~
street_lamps.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %s", cc + 1);
  ~~~~~^~~~~~~~~~~~~~~
street_lamps.cpp:49:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %s", comm);
   ~~~~~^~~~~~~~~~~~~
street_lamps.cpp:52:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d", &a, &b);
    ~~~~~^~~~~~~~~~~~~~~~
street_lamps.cpp:59:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &w);
    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 2400 KB Output is correct
2 Correct 122 ms 2420 KB Output is correct
3 Correct 129 ms 2424 KB Output is correct
4 Correct 143 ms 3704 KB Output is correct
5 Correct 147 ms 2808 KB Output is correct
6 Correct 140 ms 3704 KB Output is correct
7 Correct 169 ms 2424 KB Output is correct
8 Correct 181 ms 3832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 119 ms 2400 KB Output is correct
9 Correct 122 ms 2420 KB Output is correct
10 Correct 129 ms 2424 KB Output is correct
11 Correct 143 ms 3704 KB Output is correct
12 Correct 147 ms 2808 KB Output is correct
13 Correct 140 ms 3704 KB Output is correct
14 Correct 169 ms 2424 KB Output is correct
15 Correct 181 ms 3832 KB Output is correct
16 Incorrect 6 ms 1528 KB Output isn't correct
17 Halted 0 ms 0 KB -