QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#336013#6503. DFS Order 3ucup-team1087Compile Error//C++171.2kb2024-02-24 11:16:052024-02-24 11:16:05

Judging History

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

  • [2024-02-24 11:16:05]
  • 评测
  • [2024-02-24 11:16:05]
  • 提交

answer

#include <iostream>
using namespace std;

template <class T>
T uread() {
    char c = getchar();
    while (c < '0' || c > '9') {
        c = getchar();
    }
    T num = 0;
    while (c >= '0' && c <= '9') {
        num = (num << 1) + (num << 3) + (c ^ 48);
        c = getchar();
    }
    return num;
}

const int N = 1e3 + 1;

vector<int> a[N];

void solve() {
    int n = uread<int>();
    for (int i = 1; i <= n; ++i) {
        a[i].resize(n);
        for (int j = 0; j < n; ++j) {
            a[i][j] = uread<int>();
        }
    }
    
    vector<pair<int, int>> ans;
    for (int i = 1; i <= n; ++i) {
        int v = a[1].back();
        ans.push_back({a[v][0], a[v][1]});
        if (ans.back().first > ans.back().second) {
            swap(ans.back().first, ans.back().second);
        }
        for (int j = 1; j <= n; ++j) {
            a[j].erase(find(a[j].begin(), a[j].end(), v));
        }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    for (auto [u, v] : ans) {
        printf("%d %d\n", u, v);
    }
}

int main(int argc, const char * argv[]) {
    int T = uread<int>();
    while (T--) {
        solve();
    }
    return 0;
}

詳細信息

answer.code:20:1: error: ‘vector’ does not name a type
   20 | vector<int> a[N];
      | ^~~~~~
answer.code: In function ‘void solve()’:
answer.code:25:9: error: ‘a’ was not declared in this scope
   25 |         a[i].resize(n);
      |         ^
answer.code:31:5: error: ‘vector’ was not declared in this scope
   31 |     vector<pair<int, int>> ans;
      |     ^~~~~~
answer.code:2:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
answer.code:31:25: error: expected primary-expression before ‘>’ token
   31 |     vector<pair<int, int>> ans;
      |                         ^~
answer.code:31:28: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   31 |     vector<pair<int, int>> ans;
      |                            ^~~
      |                            abs
answer.code:33:17: error: ‘a’ was not declared in this scope
   33 |         int v = a[1].back();
      |                 ^
answer.code:42:5: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   42 |     sort(ans.begin(), ans.end());
      |     ^~~~
      |     short
answer.code:43:15: error: ‘unique’ was not declared in this scope
   43 |     ans.erase(unique(ans.begin(), ans.end()), ans.end());
      |               ^~~~~~