Submission #248228

#TimeUsernameProblemLanguageResultExecution timeMemory
248228lycLokahian Relics (FXCUP4_lokahia)C++17
0 / 100
2 ms640 KiB
#include "lokahia.h"
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)

int FindBase(int N){
    int x = 0, y = 1, z;
    FOR(i,1,N-1){
        if (y == 0) x = i, y = 1;
        else if (x == i || (z = CollectRelics(x,i)) != -1) x = z, ++y;
        else --y;
    }
    int c = 1;
    FOR(i,0,N-1) if (x != i) {
        if (CollectRelics(x,i) != -1) ++c;
    }
	return (c > N/2 ? x : -1);
}

Compilation message (stderr)

lokahia.cpp: In function 'int FindBase(int)':
lokahia.cpp:16:18: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
     FOR(i,0,N-1) if (x != i) {
                  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...