QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#180583#6680. HeaprgnerdplayerCompile Error//C++202.2kb2023-09-16 00:38:212023-09-16 00:38:22

Judging History

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

  • [2023-09-16 00:38:22]
  • 评测
  • [2023-09-16 00:38:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    
    auto solve = [&]() {
        int n;
        cin >> n;

        vector<int> v(n + 1), a(n + 1);
        for (int i = 1; i <= n; i++) {
            cin >> v[i];
        }
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }

        vector<int> ans(n + 1);
        bool ok = true;

        for (int i = n; i > 0; i--) {
            vector<int> path;
            int u = i;

            int isMax = -1;

            while (true) {
                if (u == 0) {
                    ok = false;
                    break;
                }
                path.push_back(u);
                if (a[u] == v[i]) {
                    if (u / 2 > 0) {
                        if (a[u / 2] > a[u]) {
                            if (isMax == 0) {
                                ok = false;
                            }
                            isMax = 1;
                        } else if (a[u / 2] < a[u]) {
                            if (isMax == 1) {
                                ok = false;
                            }
                            isMax = 0;
                        }
                    }
                    break;
                } else if (a[u] > v[i]) {
                    if (isMax == 1) {
                        ok = false;
                    }
                    isMax = 0;
                } else if (a[u] < v[i]) {
                    if (isMax == 0) {
                        ok = false;
                    }
                    isMax = 1;
                }
                u /= 2;
            }

            if (!ok) {
                cout << "Impossible\n";
                return;
            }

            ans[i] = max(0, isMax);

            while (int(path.size()) > 1) {
                swap(a[path.end()[-2]], a[path.back()]);
                path.pop_back();
            }
        }

        for (int i = 1; i <= n; i++) {
            cout << ans[i]; 
        }
        cout << '\n';
    };

    int t;
    cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}
 

Details

answer.code:93:1: error: extended character   is not valid in an identifier
   93 |  
      | ^
answer.code:93:1: error: ‘ ’ does not name a type
   93 |  
      | ^