Submission #482421

# Submission time Handle Problem Language Result Execution time Memory
482421 2021-10-24T13:38:12 Z rainboy Tenis (COCI20_tenis) C
25 / 110
52 ms 4008 KB
#include <stdio.h>

#define N	100000
#define T	3
#define S	6

int min(int a, int b) { return a < b ? a : b; }

int pref[S][T] = {
	{ 0, 1, 2 },
	{ 0, 2, 1 },
	{ 1, 0, 2 },
	{ 1, 2, 0 },
	{ 2, 0, 1 },
	{ 2, 1, 0 }
};

int main() {
	static int ii[N][T], ii_[N], ep[N][T], eo[N], kk[N], ll[N], mm[S];
	int n, g, h, i, j, j_, p, q, s, t, t_;

	scanf("%d", &n);
	for (t = 0; t < T; t++)
		for (i = 0; i < n; i++) {
			scanf("%d", &p), p--;
			ii[p][t] = i;
		}
	for (p = 0; p < n; p++) {
		ii_[p] = n;
		for (t = 0; t < T; t++)
			ii_[p] = min(ii_[p], ii[p][t]);
	}
	for (p = 0; p < n; p++) {
		i = ii_[p];
		ep[i][eo[i]++] = p;
	}
	for (i = 0; i < n; i++)
		for (g = 0; g < eo[i]; g++)
			for (h = g + 1; h < eo[i]; h++) {
				p = ep[i][g], q = ep[i][h], j_ = n, t_ = -1;
				for (t = 0; t < T; t++)
					if (ii[p][t] == i || ii[q][t] == i) {
						j = i ^ ii[p][t] ^ ii[q][t];
						if (j_ > j)
							j_ = j, t_ = t;
					}
				kk[t_]++;
				if (ii[p][t_] < ii[q][t_])
					ll[p]++;
				else
					ll[q]++;
			}
	for (i = n - 1; i >= 0; i--) {
		for (g = 0; g < eo[i]; g++) {
			p = ep[i][g];
			for (s = 0; s < S; s++) {
				for (t = 0; t < T; t++)
					if (ii[p][pref[s][t]] == i)
						break;
				kk[pref[s][t]] += mm[s], ll[p] += mm[s];
			}
		}
		for (g = 0; g < eo[i]; g++) {
			p = ep[i][g];
			for (s = 0; s < S; s++) {
				int congruent = 1;

				for (t = 1; t < T; t++)
					if (ii[p][pref[s][t - 1]] > ii[p][pref[s][t]] || ii[p][pref[s][t - 1]] == ii[p][pref[s][t]] && pref[s][t - 1] > pref[s][t]) {
						congruent = 0;
						break;
					}
				if (congruent)
					mm[s]++;
			}
		}
	}
	for (t = 0; t < T; t++)
		printf("%d ", kk[t]);
	printf("\n");
	for (p = 0; p < n; p++)
		ll[p] = -1;
	for (p = 0; p < n; p++)
		printf("%d ", ll[p]);
	printf("\n");
	return 0;
}

Compilation message

tenis.c: In function 'main':
tenis.c:69:98: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   69 |      if (ii[p][pref[s][t - 1]] > ii[p][pref[s][t]] || ii[p][pref[s][t - 1]] == ii[p][pref[s][t]] && pref[s][t - 1] > pref[s][t]) {
      |                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tenis.c:22:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
tenis.c:25:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |    scanf("%d", &p), p--;
      |    ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 204 KB Partially correct
2 Partially correct 0 ms 204 KB Partially correct
3 Partially correct 0 ms 204 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 204 KB Partially correct
2 Partially correct 0 ms 204 KB Partially correct
3 Partially correct 0 ms 204 KB Partially correct
4 Partially correct 2 ms 332 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 204 KB Partially correct
2 Partially correct 0 ms 204 KB Partially correct
3 Partially correct 0 ms 204 KB Partially correct
4 Partially correct 2 ms 332 KB Partially correct
5 Partially correct 24 ms 1780 KB Partially correct
6 Partially correct 42 ms 2528 KB Partially correct
7 Partially correct 45 ms 3268 KB Partially correct
8 Partially correct 52 ms 4008 KB Partially correct
9 Incorrect 46 ms 3240 KB Output isn't correct
10 Halted 0 ms 0 KB -