QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#199718 | #7346. Frogs | Vengeful_Spirit# | WA | 0ms | 5676kb | C++14 | 1.0kb | 2023-10-04 13:49:59 | 2023-10-04 13:49:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, a[N], b[N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
bool fl = 1;
for(int i = 1; i < n; ++i) {
cin >> a[i];
b[i] = i;
if(a[i] %2 == 1) fl = 0;
a[i] /= 2;
}b[n] = n;
if(!fl) {
cout << "NO\n";
return 0;
}
// cout << "!";
vector<int> st;
a[0] = a[n] = 0;
for(int i = 1; i <= n; ++i) {
// cout << a[i] << " ";
if(a[i]>a[i-1]) {
if(a[i] > a[i-1] + 1) {
cout << "NO\n";
return 0;
}
st.push_back(i);
}
if(a[i]<a[i-1]) {
if(a[i] < a[i-1] - 1) {
cout << "NO\n";
return 0;
}
swap(b[st.back()], b[i]);
st.pop_back();
}
}
cout << "YES\n";
for(int i = 1; i <= n; ++i) {
cout << b[i] << " ";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5676kb
input:
5 2 4 2 2
output:
YES 5 3 2 4 1
result:
wrong answer Line [name=verdict] equals to "YES", doesn't correspond to pattern "Yes|No"