結果

問題 No.466 ジオラマ
ユーザー 37zigen37zigen
提出日時 2020-04-18 08:23:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,758 bytes
コンパイル時間 2,242 ms
コンパイル使用メモリ 91,620 KB
実行使用メモリ 53,776 KB
最終ジャッジ日時 2024-10-03 22:49:26
合計ジャッジ時間 15,496 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
39,276 KB
testcase_01 AC 49 ms
36,444 KB
testcase_02 AC 79 ms
39,584 KB
testcase_03 AC 83 ms
39,788 KB
testcase_04 AC 83 ms
38,876 KB
testcase_05 AC 46 ms
36,856 KB
testcase_06 AC 147 ms
41,064 KB
testcase_07 AC 131 ms
41,044 KB
testcase_08 AC 153 ms
40,976 KB
testcase_09 AC 141 ms
40,924 KB
testcase_10 AC 150 ms
41,172 KB
testcase_11 AC 138 ms
41,112 KB
testcase_12 AC 146 ms
41,032 KB
testcase_13 AC 125 ms
41,044 KB
testcase_14 AC 123 ms
40,804 KB
testcase_15 AC 138 ms
40,828 KB
testcase_16 AC 82 ms
39,420 KB
testcase_17 AC 135 ms
41,028 KB
testcase_18 AC 135 ms
40,940 KB
testcase_19 AC 136 ms
40,948 KB
testcase_20 AC 132 ms
40,700 KB
testcase_21 AC 136 ms
40,440 KB
testcase_22 AC 155 ms
41,192 KB
testcase_23 AC 130 ms
41,020 KB
testcase_24 AC 144 ms
41,204 KB
testcase_25 AC 154 ms
41,572 KB
testcase_26 AC 128 ms
41,012 KB
testcase_27 AC 146 ms
41,436 KB
testcase_28 AC 142 ms
41,252 KB
testcase_29 AC 149 ms
41,316 KB
testcase_30 AC 138 ms
40,636 KB
testcase_31 AC 143 ms
40,684 KB
testcase_32 AC 140 ms
40,864 KB
testcase_33 WA -
testcase_34 AC 142 ms
41,036 KB
testcase_35 AC 136 ms
41,212 KB
testcase_36 WA -
testcase_37 AC 50 ms
36,656 KB
testcase_38 WA -
testcase_39 AC 46 ms
36,664 KB
testcase_40 WA -
testcase_41 AC 47 ms
36,980 KB
testcase_42 WA -
testcase_43 AC 47 ms
36,628 KB
testcase_44 WA -
testcase_45 AC 46 ms
36,948 KB
testcase_46 AC 125 ms
40,912 KB
testcase_47 AC 48 ms
36,668 KB
testcase_48 AC 131 ms
41,216 KB
testcase_49 AC 46 ms
36,788 KB
testcase_50 AC 134 ms
41,072 KB
testcase_51 AC 46 ms
36,568 KB
testcase_52 AC 135 ms
41,064 KB
testcase_53 AC 46 ms
36,956 KB
testcase_54 AC 126 ms
40,744 KB
testcase_55 AC 47 ms
36,792 KB
testcase_56 AC 98 ms
38,772 KB
testcase_57 AC 47 ms
36,724 KB
testcase_58 AC 83 ms
38,416 KB
testcase_59 AC 47 ms
36,912 KB
testcase_60 AC 119 ms
39,472 KB
testcase_61 AC 47 ms
36,656 KB
testcase_62 AC 101 ms
40,424 KB
testcase_63 AC 46 ms
36,828 KB
testcase_64 AC 98 ms
38,000 KB
testcase_65 AC 46 ms
36,716 KB
testcase_66 AC 140 ms
41,196 KB
testcase_67 AC 46 ms
36,980 KB
testcase_68 AC 129 ms
40,680 KB
testcase_69 AC 49 ms
36,720 KB
testcase_70 AC 133 ms
41,148 KB
testcase_71 AC 46 ms
36,464 KB
testcase_72 AC 131 ms
40,924 KB
testcase_73 AC 47 ms
36,772 KB
testcase_74 AC 136 ms
40,932 KB
testcase_75 AC 47 ms
36,960 KB
testcase_76 AC 48 ms
36,464 KB
testcase_77 AC 47 ms
36,924 KB
testcase_78 AC 49 ms
36,828 KB
testcase_79 AC 48 ms
36,732 KB
testcase_80 AC 49 ms
36,316 KB
testcase_81 AC 75 ms
37,756 KB
testcase_82 WA -
testcase_83 AC 76 ms
39,660 KB
testcase_84 AC 127 ms
41,308 KB
testcase_85 AC 149 ms
41,628 KB
testcase_86 AC 71 ms
38,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		int D=sc.nextInt();
		
		if (A==C&&B==C) {
			int N=C;
			int M=C;
			if (D<C) {
				System.out.println(-1);
			} else {
				System.out.println(N+" "+M);
				for (int i=0;i<C;++i) {
					pw.println(i+" "+(i+1)%C);
				}
			}
		} else if (A==C) {
			int d=B-C;
			int N=C+d;
			int M=N-1;
			if (D<M) {
				System.out.println(-1);
			} else {
				System.out.println(N+" "+M);
				System.out.println(0+" "+1);
				int p=2;
				for (int i=0;i<d-1;++i) pw.println(1+" "+(p++));
				for (int i=0;i<C-1;++i) pw.println(0+" "+(p++));
			}
		} else if (B==C) {
			int d=A-C;
			int N=C+d;
			int M=N-1;
			if (D<M) {
				System.out.println(-1);
			} else {
				System.out.println(N+" "+M);
				System.out.println(0+" "+1);
				int p=2;
				for (int i=0;i<d-1;++i) pw.println(0+" "+(p++));
				for (int i=0;i<C-1;++i) pw.println(1+" "+(p++));
			}
		} else {
			int N=(A-C)+(B-C)+C;
			int M=(C==0?A-1+B-1:(A-C)+(B-C)+C-1);
			if (D<M) {
				System.out.println(-1);
			} else {
				System.out.println(N+" "+M);
				int p=2;
				for (int i=0;i<A-C-1;++i) pw.println(0+" "+(p++));
				for (int i=0;i<B-C-1;++i) pw.println(1+" "+(p++));
				if (C>0) {
					pw.println(0+" "+p);
					pw.println(1+" "+p);
					int ab=p++;
					for (int i=0;i<C-1;++i) {
						pw.println(ab+" "+(p++));
					}
				}
			}
		}
		pw.close();			
		
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
	
}




class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}
0