Submission #402415

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4024152021-05-11 16:23:59rainboyTropical Garden (IOI11_garden)C11
100 / 100
2954 ms25080 KiB
#include "garden.h"
#include "gardenlib.h"
#include <stdlib.h>
#define N 150000
#define M 150000
#define Q 2000
#define L 29 /* L = floor(log2(10^9)) */
#define INF 0x3f3f3f3f
void append(int **eh, int *eo, int i, int h) {
int o = eo[i]++;
if (o >= 2 && (o & o - 1) == 0)
eh[i] = (int *) realloc(eh[i], o * 2 * sizeof *eh[i]);
eh[i][o] = h;
}
int *eh[N], eo[N], *fj[M * 2], fo[M * 2];
int qu1[M * 2], cnt1, qu2[M * 2], cnt2; char src[M * 2], dest[M * 2], visited[M * 2];
int kk[Q], ans[Q], q;
void dfs(int i, int r) {
int o, h;
visited[i] = 1;
qu2[cnt2++] = i;
if (src[i])
for (h = 0; h < q; h++) {
int p = kk[h] < cnt2 ? qu2[cnt2 - 1 - kk[h]] : qu1[(r + kk[h] - (cnt2 - 1)) % cnt1];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

garden.c: In function 'append':
garden.c:14:23: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   14 |  if (o >= 2 && (o & o - 1) == 0)
      |                     ~~^~~
garden.c: In function 'count_routes':
garden.c:64:11: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   64 |   src[h1] = 1;
      |   ~~~~~~~~^~~
garden.c:20:46: note: at offset 1061109567 to object 'src' with size 300000 declared here
   20 | int qu1[M * 2], cnt1, qu2[M * 2], cnt2; char src[M * 2], dest[M * 2], visited[M * 2];
      |                                              ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...