結果
| 問題 |
No.649 ここでちょっとQK!
|
| コンテスト | |
| ユーザー |
sntea
|
| 提出日時 | 2018-02-09 22:50:52 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 3,948 bytes |
| コンパイル時間 | 11,766 ms |
| コンパイル使用メモリ | 394,128 KB |
| 最終ジャッジ日時 | 2024-11-14 20:21:02 |
| 合計ジャッジ時間 | 12,593 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)`
--> src/main.rs:91:23
|
91 | fn op(&self, &Self) -> Self;
| ^ expected one of 9 possible tokens
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
help: explicitly ignore the parameter name
|
91 | fn op(&self, _: &Self) -> Self;
| ~~~~~~~~
warning: unused macro definition: `debug`
--> src/main.rs:39:14
|
39 | macro_rules! debug {
| ^^^^^
|
= note: `#[warn(unused_macros)]` on by default
error: could not compile `main` (bin "main") due to 1 previous error; 1 warning emitted
ソースコード
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;
fn getline() -> String {
let mut res = String::new();
std::io::stdin().read_line(&mut res).ok();
res
}
macro_rules! readl {
($t: ty) => {
{
let s = getline();
s.trim().parse::<$t>().unwrap()
}
};
($( $t: ty),+ ) => {
{
let s = getline();
let mut iter = s.trim().split(' ');
($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
}
};
}
macro_rules! readlvec {
($t: ty) => {
{
let s = getline();
let iter = s.trim().split(' ');
iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
}
}
}
macro_rules! debug {
($x: expr) => {
println!("{}: {:?}", stringify!($x), $x)
}
}
fn printiter<'a, T>(v: &'a T)
where
&'a T: std::iter::IntoIterator,
<&'a T as std::iter::IntoIterator>::Item: std::fmt::Display,
{
for (i, e) in v.into_iter().enumerate() {
if i != 0 {
print!(" ");
}
print!("{}", e);
}
println!("");
}
struct ContestPrinter {
s: String,
}
impl ContestPrinter {
fn new() -> ContestPrinter {
ContestPrinter { s: String::new() }
}
fn print<T>(&mut self, x: T)
where
T: std::fmt::Display,
{
self.s.push_str(format!("{}", x).as_str());
}
fn println<T>(&mut self, x: T)
where
T: std::fmt::Display,
{
self.s.push_str(format!("{}\n", x).as_str());
}
}
impl std::ops::Drop for ContestPrinter {
fn drop(&mut self) {
print!("{}", self.s);
}
}
trait Monoid {
fn unity() -> Self;
fn op(&self, &Self) -> Self;
}
#[derive(Clone)]
struct SegmentTree<T: Monoid + std::clone::Clone> {
dat: Vec<T>,
length: usize,
}
impl<T: Monoid + std::clone::Clone> SegmentTree<T> {
fn new(n: usize) -> SegmentTree<T> {
let mut len = 1;
while len < n {
len <<= 1;
}
SegmentTree {
dat: vec![T::unity(); len*2],
length: n,
}
}
fn len(&self) -> usize {
self.length
}
fn update(&mut self, i: usize, val: T) {
assert!(i < self.len());
let mut p = self.dat.len()/2-1+i;
self.dat[p] = val;
while p != 0 {
p = (p-1)/2;
self.dat[p] = self.dat[2*p+1].op(&self.dat[2*p+2]);
}
}
fn query(&self, l: usize, r: usize) -> T {
self.query_(l, r, 0, 0, self.dat.len()/2)
}
fn get(&self, ind: usize) -> T {
self.dat[self.dat.len()/2+ind-1].clone()
}
fn query_(&self, l: usize, r: usize, i: usize, a: usize, b: usize) -> T {
if l <= a && b <= r {
self.dat[i].clone()
} else if !(r <= a || b <= l) {
let retl = self.query_(l, r, i*2+1, a, (a+b)/2);
let retr = self.query_(l, r, i*2+2, (a+b)/2, b);
retl.op(&retr)
} else {
T::unity()
}
}
// fn debug(&self) {
// printvec(&self.dat);
// }
}
fn main() {
let mut printer = ContestPrinter::new();
let (q, k) = readl!(usize, usize);
let mut qul = std::collections::BinaryHeap::new();
let mut qur = std::collections::BinaryHeap::new();
for _ in 0..q {
let qu = readlvec!(i64);
if qu.len() == 2 {
qul.push(qu[1]);
if qul.len() > k {
qur.push(-qul.pop().unwrap());
}
} else {
if qul.len() < k {
printer.println(-1);
} else {
printer.println(qul.pop().unwrap());
if let Some(v) = qur.pop() {
qul.push(-v);
}
}
}
}
}
sntea