結果
| 問題 |
No.5016 Worst Mayor
|
| コンテスト | |
| ユーザー |
shim0
|
| 提出日時 | 2023-04-29 15:46:05 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,247 bytes |
| コンパイル時間 | 1,680 ms |
| コンパイル使用メモリ | 164,964 KB |
| 実行使用メモリ | 26,000 KB |
| スコア | 0 |
| 最終ジャッジ日時 | 2023-04-29 15:46:15 |
| 合計ジャッジ時間 | 8,236 ms |
|
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 49 |
コンパイルメッセージ
warning: unused variable: `uv`
--> Main.rs:57:13
|
57 | let uv: Vec<u32> = read_vec();
| ^^ help: if this is intentional, prefix it with an underscore: `_uv`
|
= note: `#[warn(unused_variables)]` on by default
warning: unused variable: `t`
--> Main.rs:56:25
|
56 | fn solve(&mut self, t: usize) {
| ^ help: if this is intentional, prefix it with an underscore: `_t`
warning: multiple fields are never read
--> Main.rs:5:5
|
4 | struct State {
| ----- fields in this struct
5 | h: [[bool; 14]; 13],
| ^
6 | v: [[bool; 13]; 14],
| ^
7 | dp: [[usize; 14 * 14]; 14 * 14],
| ^^
8 | sum_s: u32,
| ^^^^^
9 | paths: HashMap<(usize, usize, usize, usize), usize>,
| ^^^^^
10 | highway_count: u32,
| ^^^^^^^^^^^^^
11 | collaborator_count: u32,
| ^^^^^^^^^^^^^^^^^^
12 | money: u64,
| ^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: 3 warnings emitted
ソースコード
use std::collections::HashMap;
use std::io::{stdout, Write};
struct State {
h: [[bool; 14]; 13],
v: [[bool; 13]; 14],
dp: [[usize; 14 * 14]; 14 * 14],
sum_s: u32,
paths: HashMap<(usize, usize, usize, usize), usize>,
highway_count: u32,
collaborator_count: u32,
money: u64,
}
impl State {
fn new() -> Self {
let mut dp = [[0; 14 * 14]; 14 * 14];
for start_i in 0..14 {
for start_j in 0..14 {
for goal_i in 0..14 {
for goal_j in 0..14 {
let mut value = 0;
if start_i > goal_i {
value += start_i - goal_i;
} else {
value += goal_i - start_i;
}
if start_j > goal_j {
value += start_j - goal_j;
} else {
value += goal_j - start_j;
}
dp[start_i * 14 + start_j][goal_i * 14 + goal_j] = 1000 * value;
}
}
}
}
let mut paths = HashMap::new();
for _ in 0..3000 {
let abcd: Vec<usize> = read_vec();
let (a, b, c, d) = (abcd[0] - 1, abcd[1] - 1, abcd[2] - 1, abcd[3] - 1);
paths.insert((a, b, c, d), dp[a * 14 + b][c * 14 + d]);
}
Self {
h: [[false; 14]; 13],
v: [[false; 13]; 14],
dp,
sum_s: 0,
paths,
highway_count: 0,
collaborator_count: 1,
money: 1_000_000,
}
}
fn solve(&mut self, t: usize) {
let uv: Vec<u32> = read_vec();
println!("2");
stdout().flush().unwrap();
}
}
fn main() {
let mut state = State::new();
for t in 0..400 {
state.solve(t);
}
}
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>()
.split_whitespace()
.map(|e| e.parse().ok().unwrap())
.collect()
}
shim0