Submission #481410

#TimeUsernameProblemLanguageResultExecution timeMemory
481410rainboyKlasika (COCI20_klasika)C11
33 / 110
5022 ms3892 KiB
#include <stdio.h> #include <stdlib.h> #define N 200000 int max(int a, int b) { return a > b ? a : b; } int *ej[N], eo[N]; void append(int i, int j) { int o = eo[i]++; if (o == 0 || o >= 2 && (o & o - 1) == 0) ej[i] = (int *) realloc(ej[i], (o == 0 ? 2 : o * 2) * sizeof *ej[i]); ej[i][o] = j; } int aa[N]; int dfs(int i, int a) { int x = aa[i] ^ a, o; for (o = eo[i]; o--; ) { int j = ej[i][o]; x = max(x, dfs(j, a)); } return x; } int main() { int n, q; scanf("%d", &q); n = 1; while (q--) { static char s[8]; int i, j; scanf("%s%d", s, &i), i--; if (s[0] == 'A') { j = n++; scanf("%d", &aa[j]), aa[j] ^= aa[i]; append(i, j); } else { scanf("%d", &j), j--; printf("%d\n", dfs(j, aa[i])); } } return 0; }

Compilation message (stderr)

klasika.c: In function 'append':
klasika.c:13:33: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   13 |  if (o == 0 || o >= 2 && (o & o - 1) == 0)
      |                               ~~^~~
klasika.c:13:23: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   13 |  if (o == 0 || o >= 2 && (o & o - 1) == 0)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
klasika.c: In function 'main':
klasika.c:34:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  scanf("%d", &q);
      |  ^~~~~~~~~~~~~~~
klasika.c:40:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |   scanf("%s%d", s, &i), i--;
      |   ^~~~~~~~~~~~~~~~~~~~
klasika.c:43:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |    scanf("%d", &aa[j]), aa[j] ^= aa[i];
      |    ^~~~~~~~~~~~~~~~~~~
klasika.c:46:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |    scanf("%d", &j), j--;
      |    ^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...