Submission #1067591

#TimeUsernameProblemLanguageResultExecution timeMemory
1067591beaconmcGame (IOI14_game)C++14
42 / 100
206 ms21332 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define FOR(i,x,y) for(ll i=x; i<y; i++) #define FORNEG(i,x,y) for(ll i=x; i>y; i--) ll paths[1502][1052]; ll N = 0; ll cmp[1502]; ll find(ll a){ while (a != cmp[a]){ cmp[a] = cmp[cmp[a]]; a = cmp[a]; } return a; } void unite(ll a, ll b){ ll A = find(a); ll B = find(b); cmp[A] = B; FOR(i,0,1052){ paths[B][i] += paths[A][i]; paths[i][B] += paths[A][i]; } } void initialize(int n){ FOR(i,0,1502) cmp[i] = i; FOR(i,0,1502) FOR(j,0,1502) paths[i][j] = 1; } int hasEdge(int u, int v){ ll U = find(u); ll V = find(v); paths[U][V]--; paths[V][U]--; if (paths[U][V] == 0){ unite(u, v); return 1; } return 0; }

Compilation message (stderr)

game.cpp: In function 'void initialize(int)':
game.cpp:41:45: warning: iteration 1052 invokes undefined behavior [-Waggressive-loop-optimizations]
   41 |     FOR(i,0,1502) FOR(j,0,1502) paths[i][j] = 1;
      |                                 ~~~~~~~~~~~~^~~
game.cpp:6:33: note: within this loop
    6 | #define FOR(i,x,y) for(ll i=x; i<y; i++)
......
   41 |     FOR(i,0,1502) FOR(j,0,1502) paths[i][j] = 1;
      |                       ~~~~~~~~   
game.cpp:41:19: note: in expansion of macro 'FOR'
   41 |     FOR(i,0,1502) FOR(j,0,1502) paths[i][j] = 1;
      |                   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...