Submission #278584

#TimeUsernameProblemLanguageResultExecution timeMemory
278584rqiMeetings (JOI19_meetings)C++14
0 / 100
3025 ms1304 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pi; #define ins insert #define sz(x) (int)(x).size() #define mp make_pair #define f first #define s second const int MOD = 1000000007; const int mx = 2005; set<int> below[mx]; bool leaved[mx]; void Solve(int N) { // int x = Query(0, 1, 2); // for (int u = 0; u < N - 1; ++u) { // Bridge(u, u + 1); // } for(int i = 1; i < N; i++){ for(int j = i+1; j < N; j++){ int a = Query(0, i, j); if(a != i) below[a].ins(i); if(a != j) below[a].ins(j); } } for(int i = 0; i < N-1; i++){ int leaf; for(int j = 0; j < N; j++){ if(leaved[j]) continue; if(sz(below[j]) == 0){ leaf = j; break; } } leaved[leaf] = 1; pi cur = mp(MOD, -1); for(int j = 0; j < N; j++){ if(leaved[j]) continue; if(below[j].count(leaf)) cur = min(cur, mp(sz(below[j]), j)); } for(int j = 0; j < N; j++){ if(below[j].count(leaf)) below[j].erase(leaf); } Bridge(min(leaf, cur.s), max(leaf, cur.s)); } }

Compilation message (stderr)

meetings.cpp: In function 'void Solve(int)':
meetings.cpp:31:7: warning: 'leaf' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |   int leaf;
      |       ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...