Submission #382576

# Submission time Handle Problem Language Result Execution time Memory
382576 2021-03-27T19:01:30 Z rainboy Strange Device (APIO19_strange_device) C
10 / 100
560 ms 45792 KB
#include <stdio.h>

#define N	1000000

unsigned int X = 12345;

int rand_() {
	return (X *= 3) >> 1;
}

long long xx[N], yy[N];

void sort(int *ii, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;

		while (j < k) {
			long long c = xx[ii[j]] != xx[i_] ? xx[ii[j]] - xx[i_] : yy[ii[j]] - yy[i_];

			if (c == 0)
				j++;
			else if (c < 0) {
				tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
			}
		}
		sort(ii, l, i);
		l = k;
	}
}

int main() {
	static int ii[N];
	int n, n_, i, ans;
	long long a, b;

	scanf("%d%lld%lld", &n, &a, &b);
	n_ = 0;
	while (n--) {
		long long l, r;

		scanf("%lld%lld", &l, &r);
		while (l <= r) {
			xx[n_] = (l + l / b) % a, yy[n_] = l % b, n_++;
			l++;
		}
	}
	n = n_;
	for (i = 0; i < n; i++)
		ii[i] = i;
	sort(ii, 0, n);
	ans = 1;
	for (i = 1; i < n; i++)
		if (xx[ii[i]] != xx[ii[i - 1]] || yy[ii[i]] != yy[ii[i - 1]])
			ans++;
	printf("%d\n", ans);
	return 0;
}

Compilation message

strange_device.c: In function 'main':
strange_device.c:40:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   40 |  scanf("%d%lld%lld", &n, &a, &b);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.c:45:3: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   45 |   scanf("%lld%lld", &l, &r);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 44 ms 4460 KB Output is correct
3 Correct 77 ms 6252 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 12 ms 1644 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 69 ms 6252 KB Output is correct
16 Correct 26 ms 2796 KB Output is correct
17 Correct 62 ms 3436 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 43 ms 32364 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 130 ms 12996 KB Output is correct
3 Correct 185 ms 12652 KB Output is correct
4 Correct 166 ms 12652 KB Output is correct
5 Runtime error 43 ms 32364 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 560 ms 45792 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 560 ms 45792 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 560 ms 45792 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 58 ms 32148 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 44 ms 4460 KB Output is correct
3 Correct 77 ms 6252 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 12 ms 1644 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 69 ms 6252 KB Output is correct
16 Correct 26 ms 2796 KB Output is correct
17 Correct 62 ms 3436 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Runtime error 43 ms 32364 KB Execution killed with signal 11
21 Halted 0 ms 0 KB -