QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#210069 | #1460. Petr's Algorithm | jh05013 | AC ✓ | 3ms | 3084kb | Rust | 1.6kb | 2023-10-10 23:39:43 | 2023-10-10 23:39:43 |
Judging History
answer
#[allow(unused_imports)] use std::{collections::*, cmp::*, ops::*};
fn main() {
let mut oj = OJ::new();
let n: usize = oj.read();
let mut pos: Vec<i32> = vec![0; n];
for i in 0..n { pos[oj.read::<usize>()-1] = i as i32; }
oj.write(
-pos.iter().enumerate()
.map(|(p, x)| (*x)-(p as i32))
.min().unwrap()+1
, LN
);
}
///////////////////////////////////////
pub mod oj {
use std::{io::*, str::*, fmt::*};
pub struct OJ {
buffer: std::str::SplitWhitespace<'static>,
out: BufWriter<Stdout>
}
impl OJ {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
let mut inp = String::new();
stdin().read_to_string(&mut inp).unwrap();
let input = Box::leak(inp.into_boxed_str()).split_whitespace();
OJ { buffer: input, out: BufWriter::new(stdout()) }
}
pub fn try_read<T: FromStr>(&mut self) -> std::result::Result<T, &str> {
self.buffer.next().ok_or("EOF")?.parse().or(Err("Failed parse"))
}
pub fn read<T: FromStr>(&mut self) -> T { self.try_read().unwrap() }
pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
(0..n).map(|_| self.read()).collect()
}
pub fn write<T: Display>(&mut self, v: T, end: &str) {
write!(self.out, "{}{}", v, end).unwrap();
}
pub fn debug<T: Debug>(&mut self, v: T, end: &str) {
write!(self.out, "{:?}{}", v, end).unwrap();
}
pub fn quit<T: Display>(&mut self, v: T) -> ! {
self.write(v,""); self.out.flush().unwrap(); std::process::exit(0);
}
}
pub static EM: &str = "";
pub static SP: &str = " ";
pub static LN: &str = "\n";
} use oj::*;
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 2088kb
input:
40 2 3 4 1 6 5 8 9 7 11 10 12 14 13 15 17 18 16 19 20 21 23 22 25 26 24 28 27 30 29 32 33 31 35 36 37 38 34 40 39
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 2048kb
input:
40 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 2036kb
input:
99 1 2 4 5 3 6 7 9 8 10 12 11 13 15 16 17 18 19 20 14 22 23 24 21 26 25 27 28 30 31 32 33 34 35 36 29 38 37 40 41 39 42 43 45 44 47 46 48 50 49 51 52 54 55 53 56 57 58 60 61 59 62 63 64 66 65 67 69 68 70 71 72 73 75 76 74 78 79 80 77 81 82 83 85 86 84 87 89 88 90 91 92 94 95 96 93 97 99 98
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 0ms
memory: 2148kb
input:
100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 2196kb
input:
100 1 2 4 3 6 5 8 9 10 7 12 11 14 15 13 16 17 18 19 21 20 22 23 24 25 26 28 29 30 27 31 33 32 35 36 37 38 39 34 40 41 42 43 45 46 47 48 44 49 50 51 53 52 55 56 54 58 59 57 61 60 63 62 64 65 67 66 68 70 69 71 73 72 75 76 77 74 79 78 80 82 81 83 85 84 87 86 89 90 91 92 93 88 95 96 97 98 94 99 100
output:
2
result:
ok 1 number(s): "2"
Test #6:
score: 0
Accepted
time: 0ms
memory: 2192kb
input:
100 1 2 3 4 6 5 9 10 8 11 13 12 7 15 17 18 19 20 21 16 23 22 25 14 27 26 29 30 31 24 28 34 35 32 33 36 38 39 37 42 41 44 43 45 46 47 49 40 48 50 52 54 55 51 57 53 56 60 58 59 61 62 64 63 66 68 69 65 71 67 72 70 74 76 77 78 73 79 75 81 80 82 85 86 87 88 89 84 91 83 92 94 93 95 90 97 98 99 96 100
output:
3
result:
ok 1 number(s): "3"
Test #7:
score: 0
Accepted
time: 0ms
memory: 2148kb
input:
100 4 5 3 6 7 9 2 11 10 12 1 13 16 8 15 18 19 14 21 17 23 25 20 27 26 28 24 29 32 33 31 22 34 35 38 36 37 41 42 39 44 30 46 40 47 48 45 43 49 53 51 55 54 57 58 50 56 61 52 63 59 64 66 67 68 62 60 65 72 70 69 73 75 71 78 79 80 76 77 81 82 84 74 85 87 86 83 88 92 93 94 95 90 89 96 91 98 97 100 99
output:
4
result:
ok 1 number(s): "4"
Test #8:
score: 0
Accepted
time: 0ms
memory: 1944kb
input:
100 3 6 5 2 9 1 8 4 12 11 13 14 7 15 18 17 16 20 22 19 23 24 25 27 29 28 31 21 10 34 33 35 32 26 37 30 40 38 39 42 44 43 36 41 45 46 47 50 48 52 49 55 54 51 57 53 60 58 56 61 59 66 62 67 68 69 71 64 65 63 72 70 73 74 77 76 75 81 80 83 78 79 87 82 85 84 90 89 86 91 92 94 88 93 98 100 96 99 95 97
output:
5
result:
ok 1 number(s): "5"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3084kb
input:
100000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...
output:
1
result:
ok 1 number(s): "1"
Test #10:
score: 0
Accepted
time: 3ms
memory: 2864kb
input:
100000 2 1 4 5 6 7 8 9 3 11 10 12 13 14 15 17 18 19 16 21 20 23 24 25 22 26 28 27 29 31 30 32 33 35 36 34 38 39 40 41 42 37 43 44 46 47 48 45 50 49 52 53 51 54 55 57 56 58 59 61 60 63 64 65 62 66 68 69 67 70 72 71 73 74 75 76 77 78 80 81 79 82 84 83 85 87 86 89 88 91 90 92 94 93 95 97 96 99 100 98 1...
output:
2
result:
ok 1 number(s): "2"
Test #11:
score: 0
Accepted
time: 3ms
memory: 2980kb
input:
100000 2 4 1 3 6 8 7 9 10 11 5 13 15 14 16 12 19 18 21 17 20 23 25 26 27 28 24 30 29 31 22 34 33 32 36 35 39 38 41 37 43 40 44 42 46 48 47 49 51 45 50 54 53 52 57 56 55 58 61 59 60 62 64 63 67 66 69 68 70 72 73 74 65 75 71 78 76 79 80 82 77 83 84 86 81 88 89 87 91 85 93 92 90 96 94 95 98 99 97 102 1...
output:
3
result:
ok 1 number(s): "3"
Test #12:
score: 0
Accepted
time: 0ms
memory: 2940kb
input:
100000 3 4 6 7 5 8 9 1 12 13 2 11 14 16 15 19 17 21 18 22 24 10 20 23 28 29 25 26 32 33 31 30 35 34 37 27 40 38 36 42 44 41 39 47 43 49 50 46 48 51 45 52 53 54 55 58 60 57 61 59 64 56 65 67 62 66 69 68 71 72 63 73 75 76 70 79 80 77 81 78 74 84 85 86 87 88 82 83 90 89 94 91 96 95 98 99 93 101 92 100 ...
output:
4
result:
ok 1 number(s): "4"
Test #13:
score: 0
Accepted
time: 3ms
memory: 2984kb
input:
100000 5 1 2 4 7 9 3 8 10 6 14 11 15 16 19 12 20 22 17 21 24 25 26 27 28 30 31 13 33 29 23 34 18 32 39 40 37 36 35 43 45 38 44 46 49 41 48 52 53 54 51 42 47 57 55 59 60 61 63 62 50 56 65 67 66 58 71 72 68 73 69 76 64 78 75 74 81 80 83 79 85 84 87 77 88 89 91 92 90 94 70 86 96 82 97 99 101 100 102 10...
output:
5
result:
ok 1 number(s): "5"
Test #14:
score: 0
Accepted
time: 3ms
memory: 2900kb
input:
100000 8 2 4 7 14 1 3 11 13 18 6 12 20 15 23 9 26 27 25 17 19 30 10 28 16 24 36 29 33 31 5 37 41 38 21 43 35 40 22 48 46 47 52 50 54 55 44 45 32 58 49 59 53 63 34 51 64 56 39 66 61 42 57 67 68 71 74 69 77 78 75 65 81 79 82 85 70 76 62 89 90 91 87 80 94 84 95 97 83 93 96 98 101 72 92 100 73 86 108 99...
output:
10
result:
ok 1 number(s): "10"
Test #15:
score: 0
Accepted
time: 1ms
memory: 2944kb
input:
100000 75 35 73 61 27 56 54 3 6 1 22 2 112 97 88 78 90 84 38 59 43 21 68 58 124 33 108 14 86 5 104 85 48 103 77 100 70 39 28 4 139 7 9 17 71 40 12 89 26 98 23 128 151 60 76 140 81 19 132 107 67 102 62 18 120 142 115 159 145 164 155 46 105 135 169 136 171 36 166 110 179 116 173 114 157 144 175 41 101...
output:
100
result:
ok 1 number(s): "100"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3000kb
input:
100000 78 974 301 865 908 314 813 1156 441 141 930 951 766 508 515 669 406 1170 1103 1210 477 402 455 822 365 223 762 934 24 689 890 1194 377 628 108 521 276 643 787 1187 977 1019 292 453 255 354 1104 1176 827 209 125 75 342 969 665 1239 444 1091 815 697 7 1171 94 345 965 657 261 1042 950 155 655 10...
output:
1243
result:
ok 1 number(s): "1243"
Test #17:
score: 0
Accepted
time: 3ms
memory: 2860kb
input:
100000 1883 2333 3578 4522 4622 4787 4180 3036 2715 3632 848 4570 736 3064 2338 750 4722 1504 3080 134 841 4595 1498 581 1587 853 3028 2760 2934 2089 1261 1502 3243 1040 4329 4542 1851 3538 994 2994 3429 3305 3990 1712 4325 3490 1896 2794 4232 4390 1699 175 4509 1764 4803 3230 3697 3500 208 988 1856...
output:
4999
result:
ok 1 number(s): "4999"
Test #18:
score: 0
Accepted
time: 3ms
memory: 2880kb
input:
100000 3805 548 603 1583 3320 3421 2330 1200 3768 2355 3731 3812 3928 2949 1288 2811 4390 2644 131 3505 1873 757 470 4583 4955 3581 4295 3124 4338 4299 2300 688 1104 4067 4653 2334 4383 2010 4652 2116 4970 2315 3934 2042 2380 4343 4751 4129 4537 3113 635 2147 2055 1478 395 4994 1459 4287 4220 4448 1...
output:
5000
result:
ok 1 number(s): "5000"