結果
| 問題 |
No.3126 Dual Query Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-25 21:41:21 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 2,000 ms |
| コード長 | 3,523 bytes |
| コンパイル時間 | 13,945 ms |
| コンパイル使用メモリ | 379,900 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 02:42:27 |
| 合計ジャッジ時間 | 23,079 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cell::RefCell;
use std::cmp::{Ordering, Reverse};
use std::collections::btree_map::Entry as BTreeMapEntry;
use std::collections::hash_map::{Entry as HashMapEntry, Entry};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::{Debug, Display, Formatter, Write};
use std::hash::Hash;
use std::io::{stdin, BufRead, BufWriter, Write as _};
use std::ops::{Bound, ControlFlow, Range, RangeBounds, RangeInclusive};
use std::rc::Rc;
use std::str::FromStr;
use std::sync::atomic;
use std::sync::atomic::AtomicUsize;
use std::thread::LocalKey;
use std::time::{Duration, Instant};
use std::{array, convert, io, iter, mem, ptr};
pub fn solve(InputObject { cin }: InputObject) {
let n: usize = cin.next();
let mut q: usize = cin.next();
let x: Vec<usize> = cin.next_vec(n);
let mut initialized = HashSet::new();
let mut out = String::from("Yes\n");
'block: {
for &x in x.iter() {
if initialized.insert(x) {
writeln!(out, "1 {x} {x}").unwrap();
if q == 0 {
break 'block;
}
q -= 1;
}
writeln!(out, "2 {x}").unwrap();
if q == 0 {
break 'block;
}
q -= 1;
}
while q > 0 {
writeln!(out, "1 1 1").unwrap();
q -= 1;
}
print!("{out}");
return;
}
println!("No");
}
pub struct InputObject<'a> {
cin: &'a mut ConsoleInput,
}
fn input(cin: &mut ConsoleInput) -> InputObject {
InputObject { cin }
}
pub fn main() {
let mut cin = ConsoleInput::new();
let input = input(&mut cin);
solve(input);
}
// libraries below
pub struct ConsoleInput {
queue: VecDeque<String>,
}
pub trait Input {
fn next<T: FromStr>(&mut self) -> T;
fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
(0..n).map(|_| self.next()).collect()
}
}
pub trait Output {
fn write(&self);
}
impl Output for () {
fn write(&self) {}
}
impl Input for ConsoleInput {
fn next<T: FromStr>(&mut self) -> T {
match self.read().parse() {
Ok(value) => value,
_ => panic!("parse error"),
}
}
}
impl ConsoleInput {
fn new() -> Self {
Self {
queue: VecDeque::new(),
}
}
fn read(&mut self) -> String {
loop {
if let Some(s) = self.queue.pop_front() {
return s;
}
let mut s = String::new();
stdin().read_line(&mut s).expect("failed to read");
for s in s.split_ascii_whitespace() {
self.queue.push_back(String::from(s));
}
}
}
}
fn binary_search(range: Range<usize>, f: impl Fn(usize) -> Ordering) -> Result<usize, usize> {
let mut start = range.start;
let mut len = range.len();
if len == 0 {
return Err(0);
}
while len > 1 {
let half = len / 2;
let mid = start + half;
if f(mid) != Ordering::Greater {
start = mid;
}
len -= half;
}
match f(start) {
Ordering::Equal => Ok(start),
Ordering::Less => Err(start + 1),
Ordering::Greater => Err(start),
}
}
fn all_bits() -> impl Iterator<Item = impl Iterator<Item = (usize, bool)>> {
(0usize..).map(|i| (0usize..).map(move |j| (j, (i >> j) & 1 != 0)))
}
#[cfg(test)]
mod tests;