Submission #278587

#TimeUsernameProblemLanguageResultExecution timeMemory
278587rqiMeetings (JOI19_meetings)C++14
29 / 100
3064 ms2592 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++){ //cout << "Phase " << i << "\n"; int leaf; for(int j = 1; j < N; j++){ if(leaved[j]) continue; if(sz(below[j]) == 0){ leaf = j; break; } } //cout << leaf << "\n"; 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)); } if(cur.s == -1) cur.s = 0; 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:32:7: warning: 'leaf' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |   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...