제출 #1068132

#제출 시각아이디문제언어결과실행 시간메모리
1068132LittleOrangeSplit the Attractions (IOI19_split)C++17
18 / 100
53 ms12112 KiB
#include "split.h"

#include<bits/stdc++.h>
using namespace std;
using ll = int;

vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
	vector<vector<ll>> con(n);
	ll m = p.size();
	for(ll i = 0;i<m;i++){
		con[p[i]].push_back(q[i]);
		con[q[i]].push_back(p[i]);
	}
	ll mxd = 0;
	for(auto &o : con) mxd = max(mxd,(ll)o.size());
	if (mxd==2){
		ll st = 0;
		for(ll i = 0;i<n;i++) if(con[i].size()==1) st = i;
		vector<ll> v(1,st);
		vector<ll> u(n,0);
		u[st] = 1;
		while(v.size()<n){
			for(ll i : con[st]) if(!u[i]){
				u[i] = 1;
				v.push_back(i);
				st = i;
				break;
			}
		}
		vector<ll> ret(n,0);
		for(ll i = 0;i<a;i++) ret[v[i]] = 1;
		for(ll i = a;i<a+b;i++) ret[v[i]] = 2;
		for(ll i = a+b;i<a+b+c;i++) ret[v[i]] = 3;
		return ret;
	}
	if (a==1){
		vector<ll> r(n,0);
		function<void(ll)> dfs;
		dfs = [&](ll i){
			if (r[i]||b==0) return;
			r[i] = 2;
			b--;
			for(ll j : con[i]){
				dfs(j);
			}
		};
		dfs(0);
		for(ll i = 0;i<n;i++)if(!r[i]){
			if (a){
				a=0;
				r[i] = 1;
			}else r[i] = 3;
		}
		return r;
	}
	vector<int> res;
	if (n == 9) {
		res = {1, 1, 3, 1, 2, 2, 3, 1, 3};
	} else {
		res = {0, 0, 0, 0, 0, 0};
	}
	return res;
}

컴파일 시 표준 에러 (stderr) 메시지

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:22:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |   while(v.size()<n){
      |         ~~~~~~~~^~
#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...