結果

問題 No.466 ジオラマ
ユーザー 37zigen37zigen
提出日時 2020-04-18 08:39:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 3,764 bytes
コンパイル時間 2,677 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 53,900 KB
最終ジャッジ日時 2024-04-14 20:22:09
合計ジャッジ時間 15,703 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
51,992 KB
testcase_01 AC 52 ms
50,084 KB
testcase_02 AC 87 ms
52,992 KB
testcase_03 AC 95 ms
51,168 KB
testcase_04 AC 83 ms
52,680 KB
testcase_05 AC 51 ms
50,196 KB
testcase_06 AC 163 ms
53,528 KB
testcase_07 AC 146 ms
53,548 KB
testcase_08 AC 164 ms
53,152 KB
testcase_09 AC 147 ms
53,560 KB
testcase_10 AC 160 ms
53,156 KB
testcase_11 AC 163 ms
53,468 KB
testcase_12 AC 166 ms
53,548 KB
testcase_13 AC 151 ms
53,588 KB
testcase_14 AC 150 ms
53,364 KB
testcase_15 AC 155 ms
53,644 KB
testcase_16 AC 94 ms
52,792 KB
testcase_17 AC 146 ms
53,576 KB
testcase_18 AC 147 ms
53,576 KB
testcase_19 AC 151 ms
53,428 KB
testcase_20 AC 150 ms
53,544 KB
testcase_21 AC 161 ms
53,672 KB
testcase_22 AC 169 ms
53,532 KB
testcase_23 AC 148 ms
53,452 KB
testcase_24 AC 165 ms
53,600 KB
testcase_25 AC 161 ms
53,796 KB
testcase_26 AC 152 ms
53,372 KB
testcase_27 AC 162 ms
53,360 KB
testcase_28 AC 153 ms
53,656 KB
testcase_29 AC 173 ms
53,900 KB
testcase_30 AC 155 ms
53,644 KB
testcase_31 AC 158 ms
53,708 KB
testcase_32 AC 156 ms
53,636 KB
testcase_33 AC 156 ms
53,316 KB
testcase_34 AC 162 ms
53,780 KB
testcase_35 AC 153 ms
53,696 KB
testcase_36 AC 149 ms
53,464 KB
testcase_37 AC 53 ms
50,012 KB
testcase_38 AC 149 ms
53,676 KB
testcase_39 AC 52 ms
49,996 KB
testcase_40 AC 154 ms
53,520 KB
testcase_41 AC 52 ms
50,120 KB
testcase_42 AC 150 ms
53,600 KB
testcase_43 AC 53 ms
50,132 KB
testcase_44 AC 146 ms
53,516 KB
testcase_45 AC 52 ms
50,264 KB
testcase_46 AC 149 ms
53,728 KB
testcase_47 AC 53 ms
50,120 KB
testcase_48 AC 150 ms
53,092 KB
testcase_49 AC 53 ms
49,804 KB
testcase_50 AC 153 ms
53,468 KB
testcase_51 AC 52 ms
50,144 KB
testcase_52 AC 156 ms
53,580 KB
testcase_53 AC 52 ms
50,088 KB
testcase_54 AC 142 ms
53,512 KB
testcase_55 AC 54 ms
50,112 KB
testcase_56 AC 110 ms
51,788 KB
testcase_57 AC 52 ms
49,556 KB
testcase_58 AC 93 ms
51,264 KB
testcase_59 AC 52 ms
50,044 KB
testcase_60 AC 120 ms
53,544 KB
testcase_61 AC 53 ms
49,704 KB
testcase_62 AC 115 ms
51,504 KB
testcase_63 AC 51 ms
50,040 KB
testcase_64 AC 98 ms
51,432 KB
testcase_65 AC 52 ms
50,268 KB
testcase_66 AC 157 ms
53,544 KB
testcase_67 AC 51 ms
50,184 KB
testcase_68 AC 141 ms
53,756 KB
testcase_69 AC 52 ms
50,196 KB
testcase_70 AC 155 ms
53,548 KB
testcase_71 AC 52 ms
50,016 KB
testcase_72 AC 146 ms
53,340 KB
testcase_73 AC 53 ms
49,800 KB
testcase_74 AC 158 ms
53,600 KB
testcase_75 AC 52 ms
50,144 KB
testcase_76 AC 51 ms
50,060 KB
testcase_77 AC 53 ms
50,136 KB
testcase_78 AC 53 ms
49,944 KB
testcase_79 AC 53 ms
49,840 KB
testcase_80 AC 53 ms
50,104 KB
testcase_81 AC 78 ms
50,940 KB
testcase_82 AC 53 ms
50,184 KB
testcase_83 AC 77 ms
51,000 KB
testcase_84 AC 144 ms
52,104 KB
testcase_85 AC 169 ms
53,544 KB
testcase_86 AC 79 ms
51,360 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||N==1) {
				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(1+" "+0);
				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