QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#163827 | #7119. Longest Trip | Crysfly | Compile Error | / | / | C++17 | 2.4kb | 2023-09-04 15:38:17 | 2024-04-28 08:15:10 |
Judging History
你现在查看的是最新测评结果
- [2024-04-28 08:15:10]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-09-04 15:38:17]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-09-04 15:38:17]
- 提交
answer
// what is matter? never mind.
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include"longesttrip.h"
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 200005
#define inf 0x3f3f3f3f
int n;
int mp[260][260];
int Q(int i,int j){
if(mp[i][j]!=-1)return mp[i][j];
return mp[i][j]=mp[j][i]=are_connected({i},{j});
}
int Q(vi a,vi b){
if(a.size()==1 && b.size()==1) return Q(a[0],b[0]);
return are_connected(a,b);
}
void operator +=(vi&a,vi&b){
for(int x:b) a.pb(x);
}
mt19937_64 rnd(64);
vi longest_trip(int N,int D)
{
n=N;
For(i,0,n-1)For(j,0,n-1)mp[i][j]=(i==j?0:-1);
vi per(n);
iota(per.begin(),per.end(),0);
shuffle(per.begin(),per.end(),rnd);
vi a,b;
for(auto x:per){
if(!a.size()){
a.pb(x);
continue;
}
if(a.size()<b.size()) swap(a,b);
if(Q(i,a.back())) a.pb(i);
else if(b.size() && Q(i,b.back())) b.pb(i);
else reverse(b.begin(),b.end()),a+=b,b.clear(),b.pb(i);
}
if(!b.size())return a;
if(!Q(a,b))return a.size()>b.size()?a:b;
if(Q(a[0],b[0])) return reverse(a.begin(),a.end()),a+=b,a;
if(Q(a.back(),b[0])) return a+=b,a;
if(Q(a[0],b.back())) return b+=a,b;
if(Q(a.back(),b.back())) return reverse(a.begin(),a.end()),b+=a,b;
vi aa=a,bb=b;
while(a.size()>1){
int mid=a.size()>>1; vi al,ar;
For(i,0,mid-1) al.pb(a[i]);
For(i,mid,a.size()-1) ar.pb(a[i]);
if(Q(al,b)) a=al;
else a=ar;
}
while(b.size()>1){
int mid=b.size()>>1; vi bl,br;
For(i,0,mid-1) bl.pb(b[i]);
For(i,mid,b.size()-1) br.pb(b[i]);
if(Q(bl,a)) b=bl;
else b=br;
}
int u=a[0],v=b[0];
a=aa,b=bb;
For(i,0,(int)a.size()-1) if(a[i]==u)
For(j,0,(int)b.size()-1) if(b[j]==v) {
vi res;
For(p,i+1,(int)a.size()-1) res.pb(a[p]);
For(p,0,i) res.pb(a[p]);
For(p,j,(int)b.size()-1) res.pb(b[p]);
For(p,0,j-1) res.pb(b[p]);
return res;
}
assert(0);
}
Details
answer.code: In function ‘vi longest_trip(int, int)’: answer.code:61:22: error: ‘i’ was not declared in this scope 61 | if(Q(i,a.back())) a.pb(i); | ^