結果
問題 |
No.3086 Re One Two
|
ユーザー |
|
提出日時 | 2025-04-04 22:20:42 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 1,983 bytes |
コンパイル時間 | 28,551 ms |
コンパイル使用メモリ | 400,320 KB |
実行使用メモリ | 21,424 KB |
最終ジャッジ日時 | 2025-04-18 00:56:29 |
合計ジャッジ時間 | 18,238 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
//#![allow(unused)] #[allow(unused_imports)] use std::{ cell::RefCell, convert::{Infallible, TryFrom, TryInto as _}, fmt::{self, Debug, Display, Formatter,}, fs::{File}, hash::{Hash, Hasher}, iter::{Product, Sum}, marker::PhantomData, ops::{Add, AddAssign, Sub, SubAssign, Div, DivAssign, Mul, MulAssign, Neg, RangeBounds}, str::{FromStr, SplitWhitespace}, sync::{atomic::{self, AtomicU32, AtomicU64}, Once}, collections::{*, btree_map::Range}, mem::{swap}, cmp::{self, Reverse, Ordering, Eq, PartialEq, PartialOrd}, thread::LocalKey, f64::consts::PI, time::Instant, rc::Rc, io::{self, stdin, Read, read_to_string, BufWriter, BufReader, stdout, Write}, }; #[allow(unused_imports)] use proconio::{input, input_interactive, marker::{*}}; #[allow(unused_imports)] //use rand::{thread_rng, Rng, seq::SliceRandom}; #[allow(unused_imports)] //use ac_library::{*}; #[allow(dead_code)] const INF: i64 = 1<<60; #[allow(dead_code)] const MOD: i64 = 1000000007; #[allow(dead_code)] const D: [(usize, usize); 4] = [(1, 0), (0, 1), (!0, 0), (0, !0)]; //use proconio::fastout; //#[fastout] fn main() { input! { n: usize, c: [(usize, usize); n], } let mut nex = vec![!0; n]; let mut pre = !0; let mut lock = vec![false; n]; for (i, &(a, b)) in c.iter().enumerate(){ if a==1{ lock[i] = true; nex[i+1] = i; if b==1{ nex[i] = pre; } } else if b==2{ lock[i] = true; pre = i; } else if b==1{ nex[i] = pre; } } let mut cnt = 0; let mut ans = vec![0; n]; for i in 0..n{ if lock[i]{continue} let mut p = i; while p < !0{ ans[p] = cnt; p = nex[p]; cnt += 1; } } let mut res = vec!["".to_string(); n]; for i in 0..n{ res[ans[i]] = (i+1).to_string(); } println!("{}", res.join("\n")); }