結果

問題 No.466 ジオラマ
ユーザー Grenache
提出日時 2016-12-16 20:55:50
言語 Java8
(openjdk 1.8.0.222)
結果
AC  
実行時間 219 ms
コード長 2,416 Byte
コンパイル時間 2,488 ms
使用メモリ 36,668 KB
最終ジャッジ日時 2019-09-02 05:12:31

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
challenge01.txt AC 118 ms
32,520 KB
challenge02.txt AC 105 ms
31,908 KB
sample01.txt AC 109 ms
30,212 KB
sample02.txt AC 107 ms
32,736 KB
sample03.txt AC 108 ms
31,984 KB
sample04.txt AC 106 ms
32,424 KB
test000.txt AC 199 ms
35,960 KB
test001.txt AC 184 ms
35,948 KB
test01.txt AC 208 ms
35,960 KB
test02.txt AC 188 ms
36,404 KB
test03.txt AC 197 ms
35,960 KB
test04.txt AC 189 ms
36,644 KB
test05.txt AC 197 ms
34,476 KB
test06.txt AC 181 ms
35,956 KB
test07.txt AC 179 ms
35,432 KB
test08.txt AC 186 ms
36,648 KB
test09.txt AC 143 ms
32,860 KB
test10.txt AC 181 ms
35,960 KB
test010.txt AC 181 ms
36,652 KB
test11.txt AC 184 ms
36,316 KB
test12.txt AC 182 ms
36,352 KB
test13.txt AC 186 ms
35,952 KB
test14.txt AC 193 ms
35,108 KB
test15.txt AC 182 ms
36,668 KB
test16.txt AC 201 ms
36,004 KB
test17.txt AC 204 ms
35,956 KB
test18.txt AC 184 ms
35,952 KB
test19.txt AC 201 ms
35,956 KB
test020.txt AC 195 ms
36,648 KB
test20.txt AC 204 ms
35,952 KB
test21.txt AC 193 ms
35,956 KB
test22.txt AC 188 ms
35,952 KB
test23.txt AC 184 ms
36,488 KB
test24.txt AC 184 ms
36,664 KB
test030.txt AC 196 ms
35,948 KB
test040.txt AC 187 ms
35,956 KB
test100.txt AC 175 ms
35,420 KB
test101.txt AC 105 ms
32,536 KB
test110.txt AC 182 ms
34,464 KB
test111.txt AC 104 ms
31,908 KB
test120.txt AC 183 ms
35,964 KB
test121.txt AC 106 ms
32,656 KB
test130.txt AC 184 ms
35,960 KB
test131.txt AC 103 ms
31,904 KB
test140.txt AC 182 ms
35,960 KB
test141.txt AC 106 ms
32,644 KB
test200.txt AC 174 ms
33,932 KB
test201.txt AC 106 ms
30,140 KB
test210.txt AC 196 ms
35,956 KB
test211.txt AC 105 ms
31,912 KB
test220.txt AC 189 ms
35,988 KB
test221.txt AC 106 ms
30,140 KB
test230.txt AC 187 ms
34,460 KB
test231.txt AC 107 ms
30,816 KB
test240.txt AC 185 ms
36,348 KB
test241.txt AC 105 ms
31,912 KB
test300.txt AC 168 ms
34,888 KB
test301.txt AC 107 ms
31,904 KB
test310.txt AC 165 ms
31,932 KB
test311.txt AC 107 ms
30,144 KB
test320.txt AC 174 ms
35,428 KB
test321.txt AC 106 ms
31,908 KB
test330.txt AC 170 ms
33,388 KB
test331.txt AC 104 ms
31,916 KB
test340.txt AC 162 ms
34,900 KB
test341.txt AC 108 ms
32,428 KB
test400.txt AC 194 ms
35,964 KB
test401.txt AC 105 ms
31,884 KB
test410.txt AC 184 ms
34,464 KB
test411.txt AC 105 ms
32,216 KB
test420.txt AC 179 ms
35,420 KB
test421.txt AC 106 ms
32,552 KB
test430.txt AC 175 ms
35,432 KB
test431.txt AC 105 ms
31,908 KB
test440.txt AC 188 ms
36,400 KB
test441.txt AC 105 ms
34,740 KB
text001.txt AC 106 ms
31,912 KB
text011.txt AC 106 ms
31,908 KB
text021.txt AC 107 ms
32,260 KB
text031.txt AC 104 ms
30,244 KB
text041.txt AC 107 ms
31,912 KB
z001.txt AC 104 ms
31,984 KB
z002.txt AC 104 ms
31,912 KB
z003.txt AC 107 ms
32,636 KB
z004.txt AC 196 ms
36,524 KB
z005.txt AC 219 ms
36,644 KB
z006.txt AC 109 ms
32,704 KB
テストケース一括ダウンロード

ソースコード

diff #
import java.io.*;
import java.util.*;


public class Main_yukicoder466 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if (c == 0) {
			int min = a - 1 + b - 1;

			if (d < min) {
				pr.println(-1);
				return;
			}

			int n = a + b;
			pr.printf("%d %d\n", n, min);
			for (int v = 2; v < 2 + a - 1; v++) {
				pr.printf("%d %d\n", 0, v);
			}
			for (int v = a + 1; v < n; v++) {
				pr.printf("%d %d\n", 1, v);
			}
		} else if (a == c && c == b) {
			if (a == 1) {
				pr.println(-1);
				return;
			}
			int min = a - 1 + 1;

			if (d < min) {
				pr.println(-1);
				return;
			}

			int n = a;
			pr.printf("%d %d\n", n, min);
			pr.printf("%d %d\n", 0, 1);
			pr.printf("%d %d\n", 1, 0);
			for (int v = 2; v < 2 + a - 2; v++) {
				pr.printf("%d %d\n", 0, v);
			}
		} else if (a == c && c != b) {
			int min = a - 1 + 1 + b - c - 1;

			if (d < min) {
				pr.println(-1);
				return;
			}

			int n = b;
			pr.printf("%d %d\n", n, min);
			pr.printf("%d %d\n", 1, 0);
			for (int v = 2; v < 2 + a - 1; v++) {
				pr.printf("%d %d\n", 0, v);
			}
			for (int v = a + 1; v < n; v++) {
				pr.printf("%d %d\n", 1, v);
			}
		} else if (a != c && c == b) {
			int min = b - 1 + 1 + a - c - 1;

			if (d < min) {
				pr.println(-1);
				return;
			}

			int n = a;
			pr.printf("%d %d\n", n, min);
			pr.printf("%d %d\n", 0, 1);
			for (int v = 2; v < 2 + b - 1; v++) {
				pr.printf("%d %d\n", 1, v);
			}
			for (int v = b + 1; v < n; v++) {
				pr.printf("%d %d\n", 0, v);
			}
		} else {
			int min = a + b - c - 1;

			if (d < min) {
				pr.println(-1);
				return;
			}

			int n = a + b - c;
			pr.printf("%d %d\n", n, min);
			for (int v = 2; v < 2 + a - c - 1; v++) {
				pr.printf("%d %d\n", 0, v);
			}
			for (int v = a - c + 1; v < n - c; v++) {
				pr.printf("%d %d\n", 1, v);
			}
			pr.printf("%d %d\n", 0, n - c);
			pr.printf("%d %d\n", 1, n - c);
			for (int v = n - c + 1; v < n; v++) {
				pr.printf("%d %d\n", n - c, v);
			}
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0