結果

問題 No.466 ジオラマ
ユーザー antaanta
提出日時 2016-12-16 00:30:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,818 bytes
コンパイル時間 1,913 ms
コンパイル使用メモリ 169,488 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-20 08:13:11
合計ジャッジ時間 5,872 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,388 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 4 ms
4,384 KB
testcase_13 AC 3 ms
4,384 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 4 ms
4,380 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 3 ms
4,380 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 3 ms
4,380 KB
testcase_34 AC 3 ms
4,376 KB
testcase_35 AC 3 ms
4,384 KB
testcase_36 AC 3 ms
4,384 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 3 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 3 ms
4,380 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 3 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 3 ms
4,380 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 3 ms
4,384 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 AC 3 ms
4,376 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 3 ms
4,380 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 1 ms
4,380 KB
testcase_60 AC 2 ms
4,380 KB
testcase_61 AC 2 ms
4,380 KB
testcase_62 AC 2 ms
4,376 KB
testcase_63 AC 2 ms
4,380 KB
testcase_64 AC 1 ms
4,380 KB
testcase_65 AC 1 ms
4,380 KB
testcase_66 AC 3 ms
4,376 KB
testcase_67 AC 2 ms
4,380 KB
testcase_68 AC 2 ms
4,376 KB
testcase_69 AC 2 ms
4,376 KB
testcase_70 AC 2 ms
4,380 KB
testcase_71 AC 1 ms
4,380 KB
testcase_72 AC 2 ms
4,380 KB
testcase_73 AC 1 ms
4,380 KB
testcase_74 AC 3 ms
4,380 KB
testcase_75 AC 2 ms
4,380 KB
testcase_76 AC 1 ms
4,380 KB
testcase_77 AC 2 ms
4,380 KB
testcase_78 AC 2 ms
4,376 KB
testcase_79 AC 2 ms
4,380 KB
testcase_80 AC 1 ms
4,376 KB
testcase_81 AC 1 ms
4,380 KB
testcase_82 AC 1 ms
4,376 KB
testcase_83 AC 1 ms
4,380 KB
testcase_84 AC 3 ms
4,380 KB
testcase_85 AC 4 ms
4,376 KB
testcase_86 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int A; int B; int C; int D;
	while (~scanf("%d%d%d%d", &A, &B, &C, &D)) {
		int swapped = 0;
		if (A < B) swap(A, B), swapped = 1;
		int N;
		vpii edges;
		if (A == B && B == C) {
			if (A == 1) {
				N = -1;
			}
			else {
				N = 2 + (A - 2);
				edges.emplace_back(0, 1);
				edges.emplace_back(1, 0);
				rep(i, A - 2)
					edges.emplace_back(i == 0 ? 0 : 2 + i - 1, 2 + i);
			}
		}
		else if (B == C) {
			N = 2 + (A - B - 1) + (B - 1);
			rep(i, A - B - 1)
				edges.emplace_back(i == 0 ? 0 ^ swapped : 2 + i - 1, 2 + i);
			edges.emplace_back(0 ^ swapped, 1 ^ swapped);
			rep(i, B - 1)
				edges.emplace_back(i == 0 ? 1 ^ swapped : 2 + (A - B - 1) + i - 1, 2 + (A - B - 1) + i);
		}
		else {
			N = 2 + (A - 1) + (B - C - 1);
			rep(i, A - 1)
				edges.emplace_back(i == 0 ? 0 ^ swapped : 2 + i - 1, 2 + i);
			rep(i, B - C - 1)
				edges.emplace_back(i == 0 ? 1 ^ swapped : A + 1 + i - 1, A + 1 + i);
			if (0 < C)
				edges.emplace_back(1 ^ swapped, 2 + (A - C - 1));
		}
		if (N == -1 || (int)edges.size() > D) {
			puts("-1");
		}
		else {
			printf("%d %d\n", N, (int)edges.size());
			for (int i = 0; i < (int)edges.size(); ++i)
				printf("%d %d\n", edges[i].first, edges[i].second);
		}
	}
	return 0;
}
0