제출 #426887

#제출 시각아이디문제언어결과실행 시간메모리
426887dreezySplit the Attractions (IOI19_split)C++17
0 / 100
4 ms5068 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; #define pb push_back /* subtask 1, line easy, split by sections */ /* subtask 2 */ const int maxn = 1e5 + 5; vector<int> graph[maxn]; vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<int> ans(n); int m = p.size(); int cur = -1; for(int i =0; i<m ;i++){ //cout << p[i] <<", "<<q[i]<<endl; graph[p[i]].pb(q[i]); graph[q[i]].pb(p[i]); } for(int i =0; i<n; i++){ if(graph[i].size() == 1) { cur = i; break; } } vector<bool> vis(n); while(c > 0){ //cout <<cur<<endl; if(a > 0){ a--; ans[cur] = 1; }else if(b > 0){ b--; ans[cur] = 2; } else{ c--; ans[cur] = 3; } vis[cur] =true; for(int adj : graph[cur]) { if(!vis[adj]) { cur = adj; break; } } } return ans; } /************/
#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...