QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#155794#7119. Longest TripHossamHero7Compile Error//C++141.8kb2023-09-02 05:58:352024-04-28 07:45:43

Judging History

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

  • [2024-04-28 07:45:43]
  • 管理员手动重测本题所有提交记录
  • [2023-09-02 05:58:36]
  • 评测
  • [2023-09-02 05:58:35]
  • 提交

answer

#include <bits/stdc++.h>
#include "longesttrip.h"
#include "grader.cpp"
using namespace std;
typedef long long ll;
vector<vector<int>> adj;
vector<bool> vis;
vector<vector<int>> p;
vector<int> pp;
void dfs(int node){
    pp.push_back(node);
    vis[node] = 1;
    for(auto ch : adj[node]){
        if(vis[ch]) continue;
        dfs(ch);
        break;
    }
}
vector<int> longest_trip(int n, int d)
{
    if(d == 3) {
        vector<int> ans(n);
        iota(ans.begin(),ans.end(),0);
        return ans;
    }
    if(d == 2){
        vector<int> a;
        vector<int> b;
        vector<bool> rem(n,1);
        vector<int> ans;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(!are_connected({i},{j})) {
                    a.push_back(i);
                    b.push_back(j);
                    rem[i] = 0;
                    rem[j] = 0;
                }
            }
        }
        for(auto i : a) ans.push_back(i);
        for(int i=0;i<n;i++) if(rem[i]) ans.push_back(i);
        for(auto i : b) ans.push_back(i);
        return ans;
    }
    adj.clear();
    adj.resize(n);    
    vis.clear();
    vis.resize(n);
    p.clear();
    for(int i=0;i<n;i++){
        if(vis[i]) continue;
        pp.clear();
        dfs(i);
        p.push_back(pp);
    }
    vector<int> ans;
    for(auto a : p){
        vector<bool> vis(n);
        int i = 0;
        while(!vis[i]){
            vis[i] = 1;
            ans.push_back(a[i]);
            i += 2;
            if(i>=a.size()) i -= a.size();
        }
        if(a.size()>4 && a.size()%2==0){
            i = 1;
            while(!vis[i]){
                vis[i] = 1;
                ans.push_back(a[i]);
                i += 2;
                if(i>=a.size()) i -= a.size();
            }
        }
    }
    return ans;
}

详细

answer.code:3:10: fatal error: grader.cpp: No such file or directory
    3 | #include "grader.cpp"
      |          ^~~~~~~~~~~~
compilation terminated.