結果

問題 No.1306 Exactly 2 Digits
ユーザー ziitaziita
提出日時 2021-02-25 01:39:08
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 5,940 bytes
コンパイル時間 15,834 ms
コンパイル使用メモリ 382,672 KB
実行使用メモリ 25,604 KB
平均クエリ数 1236.78
最終ジャッジ日時 2024-07-17 10:35:31
合計ジャッジ時間 45,180 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
25,220 KB
testcase_01 AC 22 ms
25,220 KB
testcase_02 AC 22 ms
24,580 KB
testcase_03 AC 23 ms
25,208 KB
testcase_04 AC 24 ms
25,220 KB
testcase_05 AC 22 ms
24,836 KB
testcase_06 AC 23 ms
24,964 KB
testcase_07 AC 23 ms
25,220 KB
testcase_08 AC 23 ms
24,836 KB
testcase_09 AC 22 ms
25,220 KB
testcase_10 AC 23 ms
25,220 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 24 ms
24,836 KB
testcase_14 WA -
testcase_15 AC 23 ms
24,836 KB
testcase_16 AC 24 ms
24,836 KB
testcase_17 AC 23 ms
24,964 KB
testcase_18 WA -
testcase_19 AC 24 ms
24,580 KB
testcase_20 WA -
testcase_21 AC 23 ms
25,220 KB
testcase_22 AC 23 ms
24,836 KB
testcase_23 AC 23 ms
25,220 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 23 ms
25,092 KB
testcase_29 AC 23 ms
24,964 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 24 ms
24,836 KB
testcase_34 WA -
testcase_35 AC 24 ms
24,836 KB
testcase_36 AC 24 ms
24,836 KB
testcase_37 AC 23 ms
25,220 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 24 ms
24,580 KB
testcase_43 AC 24 ms
25,220 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 30 ms
24,964 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 34 ms
25,220 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 AC 96 ms
25,220 KB
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 WA -
testcase_95 WA -
testcase_96 WA -
testcase_97 AC 186 ms
24,964 KB
testcase_98 AC 166 ms
25,220 KB
testcase_99 WA -
testcase_100 WA -
testcase_101 WA -
testcase_102 WA -
testcase_103 WA -
testcase_104 WA -
testcase_105 WA -
testcase_106 AC 175 ms
24,836 KB
testcase_107 WA -
testcase_108 WA -
testcase_109 WA -
testcase_110 WA -
testcase_111 WA -
testcase_112 WA -
testcase_113 WA -
testcase_114 WA -
testcase_115 WA -
testcase_116 WA -
testcase_117 WA -
testcase_118 WA -
testcase_119 AC 200 ms
25,220 KB
testcase_120 WA -
testcase_121 WA -
testcase_122 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254 より

macro_rules! eprint {
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = write!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! eprintln {
    () => { eprintln!(""); };
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = writeln!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! dbg {
    ($v:expr) => {{
        let val = $v;
        eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
        val
    }}
}

macro_rules! mat {
    ($($e:expr),*) => { Vec::from(vec![$($e),*]) };
    ($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
    ($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
    ($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
    ($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
        $a$([$i])*.$f($($t),*)
    };
    ($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
        let t = $e;
        ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
    } };
}

pub fn readln() -> String {
    let mut line = String::new();
    ::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
    line
}

macro_rules! read {
    ($($t:tt),*; $n:expr) => {{
        let stdin = ::std::io::stdin();
        let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
            let line = line.unwrap();
            let mut it = line.split_whitespace();
            _read!(it; $($t),*)
        }).collect::<Vec<_>>();
        ret
    }};
    ($($t:tt),*) => {{
        let line = readln();
        let mut it = line.split_whitespace();
        _read!(it; $($t),*)
    }};
}

macro_rules! _read {
    ($it:ident; [char]) => {
        _read!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        Vec::from(_read!($it; String).into_bytes())
    };
    ($it:ident; usize1) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_read!($it; $t)),*)
    };
}


pub fn main() {
    let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 998244353;
// const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/100;
// const INF: usize = std::usize::MAX;
// const INF: i128 = std::i128::MAX/100;

fn solve() {
    let n = read!(usize);
    let total = n*n - n;
    let mut count = vec![vec![0;2*n+1];2*n+1];
    let mut list = vec![vec![vec![];2*n+1];2*n+1];
    for i in 2..=total {
        let (p,q) = query(1,i);
        let a = (n as i64 + p) as usize;
        let b = (n as i64 + q) as usize;
        count[a][b] += 1;
        list[a][b].push(i-1);
    }
    let mut ans = vec![(0,0);total];
    for a in 1..=n-1 {
        for b in 0..=n-1 {
            let mut c = vec![vec![0;2*n+1];2*n+1];
            for x in 1..=n-1 {
                for y in 0..=n-1 {
                    if (a,b)==(x,y) {
                        continue;
                    }
                    let p = n + a - x;
                    let q = n + b - y;
                    c[min(p,q)][max(p,q)] += 1;
                }
            }
            let mut flag = true;
            for x in 0..=2*n {
                for y in 0..=2*n {
                    if count[x][y]!=c[x][y] {
                        // if (a,b)==(2,1) {
                        //     println!("{} {} {}",x,y,c[x][y]);
                        // }
                        flag = false;
                    }
                }
            }
            if flag {
                // println!("{} {}",a,b);
                ans[0] = (a,b);
            }
        }
    }
    let (s,t) = (ans[0].0 as i64, ans[0].1 as i64);
    for x in 0..=2*n {
        for y in 0..=2*n {
            if count[x][y]==1 {
                let idx = list[x][y][0];
                let a = x as i64 - n as i64;
                let b = y as i64 - n as i64;
                if 1<=(s-a)&&(s-a)<=(n-1) as i64&&0<=(t-b)&&(t-b)<=(n-1) as i64 {
                    ans[idx] = ((s-a) as usize,(t-b) as usize);
                }
                else {
                    ans[idx] = ((s-b) as usize,(t-a) as usize);
                }
            }
            if count[x][y]==2 {
                let (idx1,idx2) = (list[x][y][0],list[x][y][1]);
                let a = x as i64 - n as i64;
                let b = y as i64 - n as i64;
                let (p,q) = query(idx1+1,idx2+1);
                let (a1,b1) = (s-a,t-b);
                let (a2,b2) = (s-b,t-a);
                if a1-a2==p && b1-b2==q {
                    ans[idx1] = (a1 as usize, b1 as usize);
                    ans[idx2] = (a2 as usize, b2 as usize);
                }
                else {
                    ans[idx2] = (a1 as usize, b1 as usize);
                    ans[idx1] = (a2 as usize, b2 as usize);
                }
            }
        }
    }
    print!("! ");
    for i in 0..total {
        print!("{} ",ans[i].0*n + ans[i].1);
    }
    println!();
}

fn query(x: usize, y: usize) -> (i64,i64) {
    println!("? {} {}", x, y);
    let ans = read!(i64,i64);
    ans
}

fn run() {
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    solve();
}
0