Submission #508771

#TimeUsernameProblemLanguageResultExecution timeMemory
508771rainboy별자리 (JOI12_constellation)C11
10 / 100
1 ms332 KiB
/* https://ioi.te.lv/locations/ioi06/contest/day2/points/points_sol.pdf */ #include <stdio.h> #define N 10 unsigned int X; int rand_() { return (X *= 3) >> 1; } int xx[N], yy[N], cc[N], o; long long cross(int i, int j, int k) { return (long long) (xx[j] - xx[i]) * (yy[k] - yy[i]) - (long long) (xx[k] - xx[i]) * (yy[j] - yy[i]); } 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 = cross(o, ii[j], 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, cnt, h, i, b, ans, comp; scanf("%d", &n); o = -1; for (i = 0; i < n; i++) { scanf("%d%d%d", &xx[i], &yy[i], &cc[i]), cc[i]--; if (o == -1 || xx[o] > xx[i] || xx[o] == xx[i] && yy[o] > yy[i]) o = i; ii[i] = i; } ii[0] = o, ii[o] = 0; sort(ii, 1, n); cnt = 0; for (i = 0; i < n; i++) { while (cnt >= 2 && cross(ii[cnt - 2], ii[cnt - 1], ii[i]) >= 0) cnt--; ii[cnt++] = ii[i]; } ans = 0; for (b = 1; b < (1 << n) - 1; b++) { int k; comp = 1; for (i = 0; i < n; i++) if (cc[i] != -1 && cc[i] != (b >> i & 1)) { comp = 0; break; } if (!comp) continue; k = 0; for (h = 0; h < cnt; h++) if ((b >> ii[h] & 1) != (b >> ii[(h + 1) % cnt] & 1)) k++; if (k <= 2) ans++; } printf("%d\n", ans); return 0; }

Compilation message (stderr)

constellation.c: In function 'main':
constellation.c:48:50: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   48 |   if (o == -1 || xx[o] > xx[i] || xx[o] == xx[i] && yy[o] > yy[i])
      |                                   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
constellation.c:44:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
constellation.c:47:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |   scanf("%d%d%d", &xx[i], &yy[i], &cc[i]), cc[i]--;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...