# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
482423 |
2021-10-24T13:43:40 Z |
rainboy |
Tenis (COCI20_tenis) |
C |
|
51 ms |
4292 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], ll[N], mm[S];
static long long kk[T];
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("%lld ", kk[t]);
printf("\n");
for (p = 0; p < n; p++)
printf("%d ", ll[p]);
printf("\n");
return 0;
}
Compilation message
tenis.c: In function 'main':
tenis.c:70:98: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
70 | 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:23:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
tenis.c:26:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | scanf("%d", &p), p--;
| ^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
20 ms |
1828 KB |
Output is correct |
6 |
Correct |
31 ms |
2600 KB |
Output is correct |
7 |
Correct |
43 ms |
3504 KB |
Output is correct |
8 |
Correct |
51 ms |
4292 KB |
Output is correct |
9 |
Correct |
48 ms |
3524 KB |
Output is correct |
10 |
Correct |
46 ms |
4292 KB |
Output is correct |