提出 #35047419


ソースコード 拡げる

use std::cmp::Reverse;

use proconio::input;

fn main() {
    input! {
        n: usize,
        mut s: [(i64, i64); n],
        mut t: [(i64, i64); n],
    };

    s.sort_by_key(|&(x, y)| (x, y));
    t.sort_by_key(|&(x, y)| (x, y));
    if s == t {
        println!("Yes");
        return;
    }

    s.sort_by_key(|&(x, y)| (y, x));
    t.sort_by_key(|&(x, y)| (y, x));
    if s == t {
        println!("Yes");
        return;
    }

    s.sort_by_key(|&(x, y)| (x, y));
    t.sort_by_key(|&(x, y)| (x, Reverse(y)));
    let mut y = None;
    let mut ok = true;
    for ((s_x, s_y), (t_x, t_y)) in s.iter().copied().zip(t.iter().copied()) {
        if s_x != t_x {
            ok = false;
            break;
        }
        match y {
            Some(y) => {
                if y != s_y + t_y {
                    ok = false;
                    break;
                }
            }
            None => {
                y = Some(s_y + t_y);
            }
        }
    }
    if ok {
        println!("Yes");
        return;
    }

    s.sort_by_key(|&(x, y)| (y, x));
    t.sort_by_key(|&(x, y)| (y, Reverse(x)));
    let mut x = None;
    let mut ok = true;
    for ((s_x, s_y), (t_x, t_y)) in s.iter().copied().zip(t.iter().copied()) {
        if s_y != t_y {
            ok = false;
            break;
        }
        match x {
            Some(x) => {
                if x != s_x + t_x {
                    ok = false;
                    break;
                }
            }
            None => {
                x = Some(s_x + t_x);
            }
        }
    }
    if ok {
        println!("Yes");
        return;
    }

    println!("No");
}

提出情報

提出日時
問題 I - 対称変換
ユーザ bouzuya
言語 Rust (1.42.0)
得点 6
コード長 1665 Byte
結果 AC
実行時間 218 ms
メモリ 17688 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 6 / 6
結果
AC × 3
AC × 44
セット名 テストケース
Sample example0.txt, example1.txt, example2.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, example0.txt, example1.txt, example2.txt
ケース名 結果 実行時間 メモリ
000.txt AC 5 ms 2036 KiB
001.txt AC 2 ms 1892 KiB
002.txt AC 2 ms 2136 KiB
003.txt AC 1 ms 2100 KiB
004.txt AC 2 ms 1964 KiB
005.txt AC 2 ms 2124 KiB
006.txt AC 78 ms 12956 KiB
007.txt AC 78 ms 13012 KiB
008.txt AC 79 ms 12880 KiB
009.txt AC 79 ms 13000 KiB
010.txt AC 85 ms 13000 KiB
011.txt AC 78 ms 12996 KiB
012.txt AC 78 ms 12820 KiB
013.txt AC 76 ms 12712 KiB
014.txt AC 79 ms 12856 KiB
015.txt AC 80 ms 14388 KiB
016.txt AC 86 ms 14264 KiB
017.txt AC 83 ms 14072 KiB
018.txt AC 80 ms 12980 KiB
019.txt AC 1 ms 2116 KiB
020.txt AC 53 ms 5636 KiB
021.txt AC 53 ms 5452 KiB
022.txt AC 64 ms 6200 KiB
023.txt AC 94 ms 17628 KiB
024.txt AC 92 ms 17672 KiB
025.txt AC 92 ms 17504 KiB
026.txt AC 212 ms 17432 KiB
027.txt AC 214 ms 17496 KiB
028.txt AC 214 ms 17464 KiB
029.txt AC 175 ms 17656 KiB
030.txt AC 175 ms 17396 KiB
031.txt AC 173 ms 17376 KiB
032.txt AC 213 ms 17408 KiB
033.txt AC 214 ms 17384 KiB
034.txt AC 215 ms 17688 KiB
035.txt AC 215 ms 17444 KiB
036.txt AC 215 ms 17612 KiB
037.txt AC 214 ms 17380 KiB
038.txt AC 213 ms 17516 KiB
039.txt AC 218 ms 17420 KiB
040.txt AC 212 ms 17388 KiB
example0.txt AC 2 ms 2024 KiB
example1.txt AC 1 ms 2044 KiB
example2.txt AC 1 ms 2180 KiB