QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#160472#7119. Longest TripHossamHero7Compile Error//C++141.5kb2023-09-02 20:32:242024-04-28 07:59:16

Judging History

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

  • [2024-04-28 07:59:16]
  • 管理员手动重测本题所有提交记录
  • [2023-09-02 20:32:26]
  • 评测
  • [2023-09-02 20:32:24]
  • 提交

answer

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

Details

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