Submission #979415

#TimeUsernameProblemLanguageResultExecution timeMemory
979415AdamGSSplit the Attractions (IOI19_split)C++17
40 / 100
97 ms30884 KiB
#include "split.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=1e5+7; vector<int>V[LIM], G[LIM], P[LIM], ans; vector<pair<int,int>>S; int odl[LIM], pre[LIM], ile[LIM], lpre; void DFS(int x) { pre[x]=++lpre; ile[x]=1; for(auto i : V[x]) { if(!pre[i]) { G[x].pb(i); DFS(i); ile[x]+=ile[i]; } else if(pre[i]<pre[x]) P[x].pb(i); } } void DFS2(int x, int k) { if(!S[k].st || ans[x]) return; ans[x]=S[k].nd; --S[k].st; for(auto i : G[x]) DFS2(i, k); } vector<int>find_split(int n, int a, int b, int c, vector<int>p, vector<int>q) { rep(i, n) ans.pb(0); S.pb({a, 1}); S.pb({b, 2}); S.pb({c, 3}); sort(all(S)); rep(i, p.size()) { V[p[i]].pb(q[i]); V[q[i]].pb(p[i]); } DFS(0); rep(j, 2) { rep(i, n) if(ile[i]>=S[0].st && n-ile[i]>=S[1].st) { DFS2(i, 0); DFS2(0, 1); rep(l, n) if(!ans[l]) ans[l]=S[2].nd; return ans; } swap(S[0], S[1]); } return ans; }

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
split.cpp:37:3: note: in expansion of macro 'rep'
   37 |   rep(i, p.size()) {
      |   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...