結果

問題 No.646 逆ピラミッド
ユーザー snteasntea
提出日時 2018-02-09 22:21:52
言語 Rust
(1.77.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,011 bytes
コンパイル時間 3,491 ms
コンパイル使用メモリ 150,124 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 04:28:00
合計ジャッジ時間 2,120 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused macro definition: `readlvec`
  --> main.rs:29:14
   |
29 | macro_rules! readlvec {
   |              ^^^^^^^^
   |
   = note: `#[warn(unused_macros)]` on by default

warning: unused macro definition: `debug`
  --> main.rs:39:14
   |
39 | macro_rules! debug {
   |              ^^^^^

warning: unused variable: `j`
  --> main.rs:93:13
   |
93 |         for j in 0..n-i {
   |             ^ help: if this is intentional, prefix it with an underscore: `_j`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: function `printiter` is never used
  --> main.rs:45:4
   |
45 | fn printiter<'a, T>(v: &'a T)
   |    ^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: 4 warnings emitted

ソースコード

diff #

// 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);
    }
}

fn main() {
    let mut printer = ContestPrinter::new();
    let n = readl!(i32);
    for i in 0..n {
        for j in 0..n-i {
            printer.print(n);
        }
        printer.println("");
    }
}
0