結果

問題 No.466 ジオラマ
ユーザー 37zigen37zigen
提出日時 2020-04-18 08:23:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,758 bytes
コンパイル時間 2,835 ms
コンパイル使用メモリ 82,052 KB
実行使用メモリ 53,888 KB
最終ジャッジ日時 2024-04-14 20:20:04
合計ジャッジ時間 17,531 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
52,724 KB
testcase_01 AC 53 ms
49,944 KB
testcase_02 AC 97 ms
52,640 KB
testcase_03 AC 98 ms
52,532 KB
testcase_04 AC 98 ms
52,412 KB
testcase_05 AC 53 ms
49,840 KB
testcase_06 AC 168 ms
53,580 KB
testcase_07 AC 164 ms
53,392 KB
testcase_08 AC 173 ms
53,644 KB
testcase_09 AC 168 ms
53,708 KB
testcase_10 AC 171 ms
53,616 KB
testcase_11 AC 164 ms
53,556 KB
testcase_12 AC 163 ms
53,680 KB
testcase_13 AC 159 ms
53,724 KB
testcase_14 AC 153 ms
53,460 KB
testcase_15 AC 162 ms
53,600 KB
testcase_16 AC 93 ms
52,720 KB
testcase_17 AC 162 ms
53,684 KB
testcase_18 AC 161 ms
53,460 KB
testcase_19 AC 159 ms
53,580 KB
testcase_20 AC 151 ms
53,444 KB
testcase_21 AC 155 ms
53,592 KB
testcase_22 AC 168 ms
53,356 KB
testcase_23 AC 162 ms
53,728 KB
testcase_24 AC 161 ms
53,604 KB
testcase_25 AC 173 ms
53,888 KB
testcase_26 AC 164 ms
53,316 KB
testcase_27 AC 163 ms
53,544 KB
testcase_28 AC 161 ms
53,440 KB
testcase_29 AC 160 ms
53,448 KB
testcase_30 AC 155 ms
53,332 KB
testcase_31 AC 162 ms
53,464 KB
testcase_32 AC 163 ms
53,768 KB
testcase_33 WA -
testcase_34 AC 162 ms
53,632 KB
testcase_35 AC 166 ms
53,752 KB
testcase_36 WA -
testcase_37 AC 52 ms
50,040 KB
testcase_38 WA -
testcase_39 AC 53 ms
49,824 KB
testcase_40 WA -
testcase_41 AC 52 ms
49,928 KB
testcase_42 WA -
testcase_43 AC 51 ms
50,092 KB
testcase_44 WA -
testcase_45 AC 52 ms
50,164 KB
testcase_46 AC 153 ms
53,492 KB
testcase_47 AC 53 ms
50,192 KB
testcase_48 AC 146 ms
53,604 KB
testcase_49 AC 53 ms
50,200 KB
testcase_50 AC 162 ms
53,340 KB
testcase_51 AC 53 ms
49,796 KB
testcase_52 AC 163 ms
53,656 KB
testcase_53 AC 53 ms
49,872 KB
testcase_54 AC 153 ms
53,624 KB
testcase_55 AC 52 ms
49,928 KB
testcase_56 AC 118 ms
53,228 KB
testcase_57 AC 55 ms
50,180 KB
testcase_58 AC 91 ms
51,296 KB
testcase_59 AC 52 ms
50,148 KB
testcase_60 AC 139 ms
53,648 KB
testcase_61 AC 52 ms
50,092 KB
testcase_62 AC 112 ms
52,000 KB
testcase_63 AC 53 ms
49,980 KB
testcase_64 AC 113 ms
51,560 KB
testcase_65 AC 53 ms
49,744 KB
testcase_66 AC 158 ms
53,352 KB
testcase_67 AC 53 ms
49,900 KB
testcase_68 AC 149 ms
53,672 KB
testcase_69 AC 53 ms
49,804 KB
testcase_70 AC 159 ms
53,488 KB
testcase_71 AC 52 ms
50,168 KB
testcase_72 AC 144 ms
53,684 KB
testcase_73 AC 53 ms
49,904 KB
testcase_74 AC 164 ms
53,676 KB
testcase_75 AC 53 ms
49,864 KB
testcase_76 AC 53 ms
49,836 KB
testcase_77 AC 53 ms
49,904 KB
testcase_78 AC 52 ms
49,864 KB
testcase_79 AC 53 ms
50,260 KB
testcase_80 AC 52 ms
50,164 KB
testcase_81 AC 79 ms
51,196 KB
testcase_82 WA -
testcase_83 AC 94 ms
52,640 KB
testcase_84 AC 149 ms
52,500 KB
testcase_85 AC 170 ms
53,572 KB
testcase_86 AC 80 ms
51,328 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