Submission #382584

# Submission time Handle Problem Language Result Execution time Memory
382584 2021-03-27T19:27:53 Z rainboy Street Lamps (APIO19_street_lamps) C
40 / 100
140 ms 2924 KB
#include <stdio.h>

#define N	300000
#define Q	300000
#define S	100

int main() {
	static char cc[N + 1];
	static int ll[S][S], ans[N];
	int n, q, h, h_, i;

	scanf("%d%d%s", &n, &q, cc);
	if (n <= 100 && q <= 100) {
		for (h = 0; h < q; h++) {
			static char s[8];

			scanf("%s", s);
			for (i = 0; i < n; i++)
				ll[h][i] = cc[i] == '0' ? i + 1 : (i == 0 ? 0 : ll[h][i - 1]);
			if (s[0] == 't') {
				scanf("%d", &i), i--;
				cc[i] = (cc[i] - '0' ^ 1) + '0';
			} else {
				int l, r, cnt;

				scanf("%d%d", &l, &r), l--, r -= 2;
				cnt = 0;
				for (h_ = 0; h_ <= h; h_++)
					if (ll[h_][r] <= l)
						cnt++;
				printf("%d\n", cnt);
			}
		}
	} else
		for (h = 1; h <= q; h++) {
			static char s[8];

			scanf("%s", s);
			if (s[0] == 't') {
				scanf("%d", &i), i--;
				if (cc[i] == '0')
					cc[i] = '1', ans[i] -= h;
				else
					cc[i] = '0', ans[i] += h;
			} else {
				int l, r;

				scanf("%d%d", &l, &r), l--, r -= 2;
				printf("%d\n", ans[l] + (cc[l] == '0' ? 0 : h));
			}
		}
	return 0;
}

Compilation message

street_lamps.c: In function 'main':
street_lamps.c:22:20: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   22 |     cc[i] = (cc[i] - '0' ^ 1) + '0';
      |              ~~~~~~^~~~~
street_lamps.c:12:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d%d%s", &n, &q, cc);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.c:17:4: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   17 |    scanf("%s", s);
      |    ^~~~~~~~~~~~~~
street_lamps.c:21:5: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   21 |     scanf("%d", &i), i--;
      |     ^~~~~~~~~~~~~~~
street_lamps.c:26:5: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   26 |     scanf("%d%d", &l, &r), l--, r -= 2;
      |     ^~~~~~~~~~~~~~~~~~~~~
street_lamps.c:38:4: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   38 |    scanf("%s", s);
      |    ^~~~~~~~~~~~~~
street_lamps.c:40:5: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   40 |     scanf("%d", &i), i--;
      |     ^~~~~~~~~~~~~~~
street_lamps.c:48:5: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   48 |     scanf("%d%d", &l, &r), l--, r -= 2;
      |     ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory 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 364 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
# Verdict Execution time Memory Grader output
1 Correct 97 ms 1260 KB Output is correct
2 Correct 96 ms 1260 KB Output is correct
3 Correct 99 ms 1248 KB Output is correct
4 Correct 110 ms 2560 KB Output is correct
5 Correct 117 ms 2924 KB Output is correct
6 Correct 105 ms 2412 KB Output is correct
7 Correct 137 ms 1388 KB Output is correct
8 Correct 140 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 364 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 97 ms 1260 KB Output is correct
9 Correct 96 ms 1260 KB Output is correct
10 Correct 99 ms 1248 KB Output is correct
11 Correct 110 ms 2560 KB Output is correct
12 Correct 117 ms 2924 KB Output is correct
13 Correct 105 ms 2412 KB Output is correct
14 Correct 137 ms 1388 KB Output is correct
15 Correct 140 ms 2552 KB Output is correct
16 Incorrect 1 ms 364 KB Output isn't correct
17 Halted 0 ms 0 KB -