結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | ziita |
提出日時 | 2021-02-25 02:07:53 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 282 ms / 2,000 ms |
コード長 | 7,120 bytes |
コンパイル時間 | 13,346 ms |
コンパイル使用メモリ | 402,424 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 1236.78 |
最終ジャッジ日時 | 2024-07-17 10:36:09 |
合計ジャッジ時間 | 33,067 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
25,220 KB |
testcase_01 | AC | 22 ms
25,220 KB |
testcase_02 | AC | 22 ms
25,220 KB |
testcase_03 | AC | 22 ms
24,836 KB |
testcase_04 | AC | 23 ms
24,836 KB |
testcase_05 | AC | 22 ms
25,220 KB |
testcase_06 | AC | 21 ms
24,848 KB |
testcase_07 | AC | 22 ms
24,836 KB |
testcase_08 | AC | 22 ms
24,836 KB |
testcase_09 | AC | 22 ms
24,836 KB |
testcase_10 | AC | 22 ms
24,580 KB |
testcase_11 | AC | 23 ms
24,836 KB |
testcase_12 | AC | 22 ms
24,836 KB |
testcase_13 | AC | 21 ms
25,220 KB |
testcase_14 | AC | 22 ms
24,836 KB |
testcase_15 | AC | 21 ms
24,580 KB |
testcase_16 | AC | 22 ms
24,964 KB |
testcase_17 | AC | 21 ms
25,208 KB |
testcase_18 | AC | 21 ms
25,220 KB |
testcase_19 | AC | 22 ms
25,220 KB |
testcase_20 | AC | 22 ms
24,964 KB |
testcase_21 | AC | 21 ms
24,836 KB |
testcase_22 | AC | 21 ms
24,580 KB |
testcase_23 | AC | 23 ms
24,580 KB |
testcase_24 | AC | 23 ms
24,836 KB |
testcase_25 | AC | 22 ms
24,580 KB |
testcase_26 | AC | 23 ms
25,220 KB |
testcase_27 | AC | 25 ms
24,580 KB |
testcase_28 | AC | 21 ms
24,836 KB |
testcase_29 | AC | 21 ms
24,964 KB |
testcase_30 | AC | 21 ms
24,836 KB |
testcase_31 | AC | 22 ms
24,820 KB |
testcase_32 | AC | 21 ms
25,220 KB |
testcase_33 | AC | 22 ms
25,220 KB |
testcase_34 | AC | 22 ms
24,580 KB |
testcase_35 | AC | 22 ms
25,160 KB |
testcase_36 | AC | 22 ms
24,836 KB |
testcase_37 | AC | 22 ms
25,220 KB |
testcase_38 | AC | 23 ms
24,964 KB |
testcase_39 | AC | 23 ms
24,580 KB |
testcase_40 | AC | 22 ms
24,580 KB |
testcase_41 | AC | 22 ms
24,580 KB |
testcase_42 | AC | 23 ms
24,964 KB |
testcase_43 | AC | 23 ms
25,220 KB |
testcase_44 | AC | 24 ms
24,580 KB |
testcase_45 | AC | 24 ms
24,836 KB |
testcase_46 | AC | 25 ms
24,836 KB |
testcase_47 | AC | 26 ms
25,220 KB |
testcase_48 | AC | 27 ms
24,836 KB |
testcase_49 | AC | 28 ms
25,220 KB |
testcase_50 | AC | 29 ms
24,836 KB |
testcase_51 | AC | 30 ms
24,836 KB |
testcase_52 | AC | 36 ms
24,952 KB |
testcase_53 | AC | 35 ms
24,964 KB |
testcase_54 | AC | 35 ms
24,836 KB |
testcase_55 | AC | 39 ms
25,220 KB |
testcase_56 | AC | 44 ms
24,836 KB |
testcase_57 | AC | 42 ms
24,964 KB |
testcase_58 | AC | 46 ms
24,836 KB |
testcase_59 | AC | 45 ms
24,964 KB |
testcase_60 | AC | 54 ms
24,964 KB |
testcase_61 | AC | 58 ms
24,580 KB |
testcase_62 | AC | 60 ms
24,836 KB |
testcase_63 | AC | 66 ms
24,964 KB |
testcase_64 | AC | 64 ms
24,580 KB |
testcase_65 | AC | 70 ms
24,964 KB |
testcase_66 | AC | 78 ms
24,836 KB |
testcase_67 | AC | 81 ms
24,952 KB |
testcase_68 | AC | 84 ms
24,964 KB |
testcase_69 | AC | 93 ms
24,836 KB |
testcase_70 | AC | 97 ms
24,580 KB |
testcase_71 | AC | 103 ms
25,220 KB |
testcase_72 | AC | 107 ms
24,836 KB |
testcase_73 | AC | 111 ms
25,476 KB |
testcase_74 | AC | 129 ms
25,464 KB |
testcase_75 | AC | 128 ms
25,220 KB |
testcase_76 | AC | 146 ms
25,220 KB |
testcase_77 | AC | 163 ms
24,836 KB |
testcase_78 | AC | 171 ms
24,964 KB |
testcase_79 | AC | 185 ms
25,076 KB |
testcase_80 | AC | 196 ms
24,964 KB |
testcase_81 | AC | 186 ms
25,208 KB |
testcase_82 | AC | 218 ms
24,580 KB |
testcase_83 | AC | 238 ms
24,580 KB |
testcase_84 | AC | 246 ms
24,836 KB |
testcase_85 | AC | 282 ms
24,580 KB |
testcase_86 | AC | 232 ms
24,964 KB |
testcase_87 | AC | 247 ms
25,220 KB |
testcase_88 | AC | 282 ms
24,808 KB |
testcase_89 | AC | 239 ms
24,452 KB |
testcase_90 | AC | 247 ms
24,580 KB |
testcase_91 | AC | 227 ms
24,964 KB |
testcase_92 | AC | 240 ms
25,220 KB |
testcase_93 | AC | 246 ms
24,836 KB |
testcase_94 | AC | 216 ms
24,836 KB |
testcase_95 | AC | 231 ms
25,220 KB |
testcase_96 | AC | 215 ms
24,964 KB |
testcase_97 | AC | 234 ms
24,836 KB |
testcase_98 | AC | 209 ms
24,580 KB |
testcase_99 | AC | 226 ms
24,964 KB |
testcase_100 | AC | 227 ms
25,160 KB |
testcase_101 | AC | 247 ms
24,580 KB |
testcase_102 | AC | 214 ms
24,836 KB |
testcase_103 | AC | 222 ms
24,964 KB |
testcase_104 | AC | 233 ms
24,836 KB |
testcase_105 | AC | 255 ms
24,836 KB |
testcase_106 | AC | 221 ms
24,964 KB |
testcase_107 | AC | 257 ms
24,964 KB |
testcase_108 | AC | 251 ms
24,580 KB |
testcase_109 | AC | 270 ms
25,220 KB |
testcase_110 | AC | 226 ms
24,580 KB |
testcase_111 | AC | 250 ms
24,964 KB |
testcase_112 | AC | 208 ms
24,580 KB |
testcase_113 | AC | 274 ms
24,820 KB |
testcase_114 | AC | 263 ms
24,836 KB |
testcase_115 | AC | 245 ms
25,476 KB |
testcase_116 | AC | 282 ms
24,580 KB |
testcase_117 | AC | 249 ms
24,952 KB |
testcase_118 | AC | 269 ms
24,836 KB |
testcase_119 | AC | 251 ms
24,964 KB |
testcase_120 | AC | 221 ms
24,836 KB |
testcase_121 | AC | 241 ms
24,836 KB |
testcase_122 | AC | 239 ms
24,836 KB |
ソースコード
#![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); } } } } for i in 0..total{ for x in 0..=2*n { for y in 0..=2*n { 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 (a1,b1) = (s-a,t-b); let (a2,b2) = (s-b,t-a); let mut target = 0; let mut td = (0,0); for d in 1..total { if ans[d]==(0,0) || d==idx1 || d==idx2 { continue; } let (e,f) = (ans[d].0 as i64, ans[d].1 as i64); let mut c1 = a1 - e; let mut d1 = b1 - f; let mut c2 = a2 - e; let mut d2 = b2 - f; if (min(c1,d1),max(c1,d1)) != (min(c2,d2),max(c2,d2)) { target = d; td = (min(c1,d1),max(c1,d1)); break; } } // println!("{:?} {:?}",(a1,b1),(a2,b2)); // println!("{} {} {:?}",idx1,target,td); if target==0 { continue; } let (p,q) = query(idx1+1,target+1); if (p,q)==td { 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); } count[x][y] = 0; } } } } 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(); }