結果

問題 No.466 ジオラマ
ユーザー Grenache
提出日時 2016-12-16 20:55:50
言語 Java8
(openjdk 1.8.0.191)
結果
AC  
実行時間 219 ms
コード長 2,416 Byte
コンパイル時間 20,554 ms
使用メモリ 26,744 KB
最終ジャッジ日時 2019-04-28 03:17:48

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
challenge01.txt AC 123 ms
21,524 KB
challenge02.txt AC 108 ms
21,228 KB
sample01.txt AC 111 ms
21,344 KB
sample02.txt AC 109 ms
21,340 KB
sample03.txt AC 111 ms
21,336 KB
sample04.txt AC 107 ms
21,228 KB
test000.txt AC 201 ms
26,624 KB
test001.txt AC 187 ms
26,568 KB
test01.txt AC 209 ms
26,744 KB
test02.txt AC 192 ms
26,580 KB
test03.txt AC 200 ms
26,620 KB
test04.txt AC 193 ms
26,608 KB
test05.txt AC 204 ms
26,612 KB
test06.txt AC 191 ms
26,564 KB
test07.txt AC 183 ms
26,116 KB
test08.txt AC 190 ms
26,580 KB
test09.txt AC 147 ms
22,500 KB
test10.txt AC 189 ms
26,572 KB
test010.txt AC 185 ms
26,576 KB
test11.txt AC 190 ms
26,580 KB
test12.txt AC 189 ms
26,572 KB
test13.txt AC 186 ms
26,572 KB
test14.txt AC 202 ms
26,624 KB
test15.txt AC 188 ms
26,576 KB
test16.txt AC 201 ms
26,608 KB
test17.txt AC 205 ms
26,612 KB
test18.txt AC 187 ms
26,572 KB
test19.txt AC 206 ms
26,620 KB
test020.txt AC 199 ms
26,616 KB
test20.txt AC 208 ms
26,620 KB
test21.txt AC 196 ms
26,616 KB
test22.txt AC 192 ms
26,576 KB
test23.txt AC 187 ms
26,568 KB
test24.txt AC 188 ms
26,576 KB
test030.txt AC 198 ms
26,616 KB
test040.txt AC 191 ms
26,576 KB
test100.txt AC 176 ms
26,112 KB
test101.txt AC 107 ms
21,252 KB
test110.txt AC 185 ms
26,576 KB
test111.txt AC 107 ms
21,192 KB
test120.txt AC 190 ms
26,564 KB
test121.txt AC 107 ms
21,244 KB
test130.txt AC 185 ms
26,556 KB
test131.txt AC 107 ms
21,248 KB
test140.txt AC 183 ms
26,564 KB
test141.txt AC 107 ms
21,212 KB
test200.txt AC 175 ms
26,048 KB
test201.txt AC 106 ms
21,248 KB
test210.txt AC 196 ms
26,608 KB
test211.txt AC 106 ms
21,252 KB
test220.txt AC 187 ms
26,568 KB
test221.txt AC 108 ms
21,248 KB
test230.txt AC 191 ms
26,584 KB
test231.txt AC 107 ms
21,212 KB
test240.txt AC 188 ms
26,584 KB
test241.txt AC 107 ms
21,252 KB
test300.txt AC 169 ms
24,628 KB
test301.txt AC 107 ms
21,248 KB
test310.txt AC 165 ms
23,580 KB
test311.txt AC 107 ms
21,252 KB
test320.txt AC 174 ms
26,024 KB
test321.txt AC 107 ms
21,252 KB
test330.txt AC 173 ms
25,168 KB
test331.txt AC 107 ms
21,244 KB
test340.txt AC 168 ms
24,128 KB
test341.txt AC 108 ms
21,248 KB
test400.txt AC 203 ms
26,620 KB
test401.txt AC 108 ms
21,244 KB
test410.txt AC 190 ms
26,576 KB
test411.txt AC 108 ms
21,216 KB
test420.txt AC 182 ms
26,108 KB
test421.txt AC 106 ms
21,248 KB
test430.txt AC 179 ms
26,120 KB
test431.txt AC 107 ms
21,248 KB
test440.txt AC 189 ms
26,572 KB
test441.txt AC 108 ms
21,220 KB
text001.txt AC 107 ms
21,216 KB
text011.txt AC 107 ms
21,216 KB
text021.txt AC 107 ms
21,212 KB
text031.txt AC 109 ms
21,236 KB
text041.txt AC 108 ms
21,228 KB
z001.txt AC 108 ms
21,300 KB
z002.txt AC 107 ms
21,220 KB
z003.txt AC 107 ms
21,300 KB
z004.txt AC 197 ms
26,736 KB
z005.txt AC 219 ms
26,612 KB
z006.txt AC 107 ms
21,308 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