QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#292812#7119. Longest TripFeet_McYeetCompile Error//C++172.2kb2023-12-28 14:09:572024-04-28 09:15:55

Judging History

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

  • [2024-04-28 09:15:55]
  • 管理员手动重测本题所有提交记录
  • [2023-12-28 14:09:58]
  • 评测
  • [2023-12-28 14:09:57]
  • 提交

answer

#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
// #pragma GCC optimize ("Ofast")
// #pragma GCC target ("avx2")
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define el << '\n'
#define nl cout << '\n'
#define spc << ' '
#define forn(i,n) for (int i=0; i<n; i++)
#define forl(i,s,e) for (int i=s; i<e; i++)
#define pb push_back
#define fi first
#define se second
#define rsz resize
#define sz(x) ((int) x.size())
#define all(x) x.begin(), x.end()
const int inf = 1000000000;
const ll inf2 = 4000000000000000000;

vector<int> longest_trip(int N, int D) {
    int n = N;
    queue<vector<int>> ls;
    forn(i,n) ls.push({i});
    while (sz(ls) > 2) {
        vector<int> a = ls.front();
        ls.pop();
        vector<int> b = ls.front();
        ls.pop();
        vector<int> c = ls.front();
        ls.pop();
        if (are_connected({a.back()}, {b.back()})) {
            reverse(all(b));
            for (int i : b) a.pb(i);
            ls.push(a);
            ls.push(c);
            continue;
        }
        if (are_connected({a.back()}, {c.back()})) {
            reverse(all(c));
            for (int i : c) a.pb(i);
            ls.push(a);
            ls.push(b);
            continue;
        }
        reverse(all(c));
        for (int i : c) b.pb(i);
        ls.push(b);
        ls.push(a);
    }
    auto v1 = ls.front();
    ls.pop();
    auto v2 = ls.front();
    ls.pop();
    if (!are_connected(v1, v2)) {
        if (sz(v1) < sz(v2)) swap(v1, v2);
        return v1;
    }
    int l = 0, h = sz(v1);
    while (h-l > 1) {
        int m = (l+h)/2;
        vector<int> vt;
        forl(i,l,m) vt.pb(v1[i]);
        if (are_connected(vt, v2)) h = m;
        else l = m;
    }
    int i1 = l;
    l = 0; h = sz(v2);
    while (h-l > 1) {
        int m = (l+h)/2;
        vector<int> vt;
        forl(i,l,m) vt.pb(v2[i]);
        if (are_connected({v1[i1]}, vt)) h = m;
        else l = m;
    }
    int i2 = l;
    vector<int> ret;
    forl(i,i1+1,sz(v1)) ret.pb(v1[i]);
    forn(i,i1+1) ret.pb(v1[i]);
    forl(i,i2,sz(v2)) ret.pb(v2[i]);
    forn(i,i2) ret.pb(v2[i]);
    return ret;
}

详细

answer.code: In function ‘std::vector<int> longest_trip(int, int)’:
answer.code:35:13: error: ‘are_connected’ was not declared in this scope
   35 |         if (are_connected({a.back()}, {b.back()})) {
      |             ^~~~~~~~~~~~~
answer.code:42:13: error: ‘are_connected’ was not declared in this scope
   42 |         if (are_connected({a.back()}, {c.back()})) {
      |             ^~~~~~~~~~~~~
answer.code:58:10: error: ‘are_connected’ was not declared in this scope
   58 |     if (!are_connected(v1, v2)) {
      |          ^~~~~~~~~~~~~
answer.code:67:13: error: ‘are_connected’ was not declared in this scope
   67 |         if (are_connected(vt, v2)) h = m;
      |             ^~~~~~~~~~~~~
answer.code:76:13: error: ‘are_connected’ was not declared in this scope
   76 |         if (are_connected({v1[i1]}, vt)) h = m;
      |             ^~~~~~~~~~~~~