結果

問題 No.2684 折々の色
ユーザー nautnaut
提出日時 2024-03-20 23:07:37
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 3,648 bytes
コンパイル時間 1,342 ms
コンパイル使用メモリ 188,316 KB
実行使用メモリ 31,272 KB
最終ジャッジ日時 2024-03-20 23:07:51
合計ジャッジ時間 9,219 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
6,676 KB
testcase_09 WA -
testcase_10 AC 1 ms
6,676 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(non_snake_case, unused_imports, unused_must_use)]
use std::io::{self, prelude::*};
use std::str;

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());

    macro_rules! input {
        ($T: ty) => {
            scan.token::<$T>()
        };
        ($T: ty, $N: expr) => {
            (0..$N).map(|_| scan.token::<$T>()).collect::<Vec<_>>()
        };
    }

    let N = input!(usize);
    let M = input!(usize);
    let X = input!(isize, M);

    let mut C = vec![];
    let mut T = vec![];

    let mut cards = vec![];

    for i in 0..N {
        let c = input!(isize, M);
        let t = input!(isize);
        let z = c.iter().map(|&v| v * t).collect::<Vec<_>>();

        C.push(c);
        T.push(t);

        cards.push((z, i));
    }

    cards.sort();

    // for c in cards.iter() {
    //     writeln!(out, "order: {}", c.1);
    // }

    // 表が i だとして裏を決めたい
    for i in 0..N {
        let t = T[i];
        let c = &C[i];

        let mut LR = vec![];

        let mut ok = 0;
        let mut ng = N;

        for j in 0..M {
            let cj = c[j];
            let xj = X[j];

            let left = 100 - t;
            let right = 10000 * xj - 100 * t * cj;

            {
                let mut okl = ok;
                let mut okr = ng;

                while okr - okl > 1 {
                    let m = (okl + okr) / 2;

                    let c = cards[m].0[j];

                    // c * left <= right を満たす範囲の下限が知りたい
                    if !(c * left <= right) {
                        okl = m;
                    } else {
                        okr = m;
                    }
                }

                ok = okl;
            }

            {
                let mut ngl = ok;
                let mut ngr = ng;

                while ngr - ngl > 1 {
                    let m = (ngl + ngr) / 2;

                    let c = cards[m].0[j];

                    if c * left <= right {
                        ngl = m;
                    } else {
                        ngr = m;
                    }
                }

                ng = ngr;
            }

            LR.push((left, right));
        }

        for j in ok..ng {
            if cards[j].1 != i {
                let mut isok = true;

                for k in 0..M {
                    let (left, right) = LR[k];

                    if left * cards[j].0[k] != right {
                        isok = false;
                    }
                }

                if isok {
                    writeln!(out, "Yes");
                    return;
                }
            }
        }
    }

    writeln!(out, "No");
}

struct Scanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: str::SplitWhitespace<'static>,
}
impl<R: BufRead> Scanner<R> {
    fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_whitespace(),
        }
    }
    fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_whitespace())
            }
        }
    }
}
0