제출 #1062794

#제출 시각아이디문제언어결과실행 시간메모리
1062794Arapak수천개의 섬 (IOI22_islands)C++17
10 / 100
31 ms5220 KiB
#include "islands.h"
#include "bits/stdc++.h"

using namespace std;

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#ifdef DEBUG
auto& operator<<(auto& os, pair<auto, auto> &p) {
	return os<<"("<<p.first<<", "<<p.second<<")";
}
auto& operator<<(auto& os, const auto &v) {
	os<<"{";
	for(auto it=begin(v);it!=end(v);++it) {
		if(it != begin(v)) os<<", ";
		os<<(*it);
	}
	return os<<"}";
}

void dbg_out(auto... x) {
	((cerr<<' '<<x), ...) << endl;
}
#define dbg(x...) cerr<<"("<<#x<<"):", dbg_out(x);
#else
#define dbg(...)
#endif

variant<bool, vi> find_journey(int N, int M, vi U, vi V) {
	if (N == 2) {
		vi canoe_0, canoe_1;
		rep(i,0,M) {
			if(U[i] == 0) canoe_0.push_back(i);
			else canoe_1.push_back(i);
		}
		bool possible = sz(canoe_0) >= 2 && sz(canoe_1) >= 1;
		if(!possible) return false;
		vi trip;
		trip.push_back(canoe_0[0]);
		trip.push_back(canoe_1[0]);
		trip.push_back(canoe_0[1]);
		trip.push_back(canoe_0[0]);
		trip.push_back(canoe_1[0]);
		trip.push_back(canoe_0[1]);
		return trip;
	}
	int c01, c10, c02, c20;
	c01 = c10 = c02 = c20 = -1;
	rep(i,0,M) {
		if(U[i] == 0 && V[i] == 1) c01 = i;
		else if(U[i] == 1 && V[i] == 0) c10 = i;
		else if(U[i] == 0 && V[i] == 2) c02 = i;
		else if(U[i] == 2 && V[i] == 0) c20 = i;
	}
	vi trip = {
		c01, c10,
		c02, c20,
		c10, c01,
		c20, c02
	};
	return trip;
}
#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...