QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#199718#7346. FrogsVengeful_Spirit#WA 0ms5676kbC++141.0kb2023-10-04 13:49:592023-10-04 13:49:59

Judging History

你现在查看的是最新测评结果

  • [2023-10-04 13:49:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5676kb
  • [2023-10-04 13:49:59]
  • 提交

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

詳細信息

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"