QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#188277 | #5484. Ghost Leg | IsaacMoris# | RE | 0ms | 3800kb | C++14 | 837b | 2023-09-25 18:07:26 | 2023-09-25 18:07:26 |
Judging History
answer
#include<iostream>
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 100 + 5, mod = 1e9 + 7;
int a[N];
int n, m;
int solve(int pos, int i) {
if (i == m)return pos;
if (a[i] == pos) return solve(pos + 1, i + 1);
if (a[i] == pos - 1) return solve(pos - 1, i + 1);
return solve(pos, i + 1);
}
void doWork() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> a[i];
}
vector<int> ans(n);
for (int i = 1; i <= n; i++) {
ans[solve(i, 0) - 1] = i;
}
for (auto i: ans)cout << i << "\n";
}
int main() {
IO
int t = 1;
//cin >> t;
for (int i = 1; i <= t; i++) {
// cout << "Case #" << i << ": ";
doWork();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3800kb
input:
4 5 1 2 1 3 2
output:
3 4 2 1
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
7 6 6 4 2 1 3 5
output:
3 1 5 2 7 4 6
result:
ok 7 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
8 21 5 4 1 6 3 7 1 2 4 6 3 1 7 5 4 6 3 1 2 5 7
output:
1 8 6 4 5 2 7 3
result:
ok 8 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
68 392 15 55 14 39 67 7 34 60 53 22 19 24 53 40 61 19 3 28 57 54 36 52 55 43 33 24 65 59 48 6 33 12 10 63 1 9 19 34 2 4 5 37 44 57 9 38 26 11 15 15 14 67 16 1 42 48 24 39 56 21 62 38 49 4 50 49 13 2 32 31 22 37 67 66 43 25 36 1 35 50 16 65 66 48 65 40 46 38 29 51 58 23 22 56 43 4 38 5 22 19 35 44 55...
output:
5 3 1 2 8 6 11 4 9 7 12 10 16 18 14 19 13 17 20 15 23 21 22 25 27 24 29 30 32 28 26 33 31 35 41 40 38 37 34 43 44 39 45 51 47 36 49 50 48 42 56 46 52 53 55 54 64 59 57 58 61 60 65 68 66 63 62 67
result:
ok 68 lines
Test #5:
score: -100
Runtime Error
input:
89 975 62 38 16 41 43 66 77 3 50 80 9 16 35 55 4 38 3 63 19 31 74 10 70 50 80 21 68 84 43 68 50 17 81 65 57 35 18 22 37 68 13 46 59 23 76 38 36 54 12 54 84 62 40 41 87 31 61 66 2 16 21 27 8 13 3 40 24 85 37 60 40 25 81 10 48 45 23 83 10 34 25 70 7 64 22 5 70 59 46 71 50 66 9 57 55 75 72 78 71 21 25 ...