QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#854836 | #9241. Sphinx | 275307894a# | 1.5 | 69ms | 4628kb | C++20 | 3.7kb | 2025-01-12 09:47:05 | 2025-01-12 09:47:06 |
Judging History
answer
#include "sphinx.h"
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=250+5,M=(1<<28)+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int n,m;
vector<int> S[N];
int fa[N];
int GF(int x){return fa[x]^x?fa[x]=GF(fa[x]):x;}
int vis[N];
void dfs(int x,int c,vector<int> &E){
if(vis[x]) return;
vis[x]=1;
for(int i:S[x]) if(E[i-1]==c) dfs(i,c,E);
}
int qry(vector<int> E){
int w=perform_experiment(E);
fill(vis+1,vis+n+1,0);
for(int i=1;i<=n;i++) if(E[i-1]==n&&!vis[i]) dfs(i,n,E),w--;
return w;
}
void find_merge(vector<int> pos,int p,int w){
if(!w) return;
if(pos.size()==1){
fa[GF(pos[0])]=p;
return;
}
vector<int> E(n,n);
E[p-1]=-1;
int len=pos.size()/2;
vector<int> p1(pos.begin(),pos.begin()+len),p2(pos.begin()+len,pos.end());
for(int i:p1) E[i-1]=-1;
int sw=p1.size()+1-qry(E);
find_merge(p1,p,sw);find_merge(p2,p,w-sw);
}
vector<int> G[N];
int op[N],col[N],id[N];
int find(vector<int> pos,vector<int> ps,int c,int cts){
if(pos.size()==1) return pos[0];
int len=pos.size()/2;
vector<int> p1(pos.begin(),pos.begin()+len),p2(pos.begin()+len,pos.end());
vector<int> E(n,n);
for(int i:ps) for(int j:G[i]) E[j]=c;
for(int i:p1) for(int j:G[i]) E[j]=-1;
int sw=qry(E)-cts;
return find(sw==p1.size()?p2:p1,ps,c,cts);
}
void work(){
for(int i=0;i<n;i++){
vector<int> E(n,n);
for(int j=1;j<=n;j++) if(id[j]==j){
if(op[j]==1){
for(int h:G[j]) E[h-1]=i;
}else{
for(int h:G[j]) E[h-1]=-1;
}
}
int w=qry(E);
gdb(i,w,E[0],E[1],E[2],E[3]);
vector<int> pos,ps;
for(int j=1;j<=n;j++) if(fa[j]==j){
if(op[j]==-1) pos.push_back(j);
else ps.push_back(j);
}
while(1){
int sw=w;
fill(vis+1,vis+n+1,0);
for(int j=1;j<=n;j++) if(fa[j]==j&&E[j-1]==i&&!vis[j]) sw--,dfs(j,i,E);
if(sw==pos.size()) break;
int p=find(pos,ps,i,w-sw);
pos.erase(find(all(pos),p));
ps.push_back(p);
for(int j:G[p]) E[j-1]=i;col[p]=i;
}
}
}
vector<int> find_colours(int nn,vector<int> X,vector<int> Y) {
n=nn;m=X.size();
for(int i=0;i<m;i++){
S[X[i]+1].push_back(Y[i]+1);
S[Y[i]+1].push_back(X[i]+1);
}
iota(fa+1,fa+n+1,1);
for(int i=1;i<=n;i++){
vector<int> pos;
for(int j:S[i])if(j<i){
int flag=0;
for(int h:pos) if(GF(h)==GF(j)) flag=1;
if(!flag) pos.push_back(j);
}
if(pos.empty()) continue;
vector<int> E(n,n);
for(int j:pos) E[j-1]=-1;E[i-1]=-1;
find_merge(pos,i,pos.size()+1-qry(E));
}
for(int i=1;i<=n;i++) G[GF(i)].push_back(i),id[i]=GF(i);
for(int i=1;i<=n;i++) if(fa[i]==i&&!op[i]){
op[i]=-1;
for(int j:G[i]) for(int h:S[j]) op[id[h]]=1;
}
for(int i=1;i<=n;i++) if(fa[i]==i) gdb(i,op[i]);
work();
for(int i=1;i<=n;i++) if(fa[i]==i) op[i]*=-1;
work();
vector<int> ans(n);
for(int i=1;i<=n;i++) ans[i-1]=col[GF(i)];
return ans;
}
详细
Subtask #1:
score: 1.5
Acceptable Answer
Test #1:
score: 3
Accepted
time: 1ms
memory: 3844kb
input:
1978433568 2 1 0 1 1978433568 1 1978433568 1 1978433568 1 1978433568 1 1978433568 1
output:
877694080 -1 -1 877694080 0 0 877694080 1 1 877694080 -1 -1 877694080 -1 -1 877694081 0 0
result:
ok #experiments: 5
Test #2:
score: 3
Accepted
time: 0ms
memory: 3852kb
input:
1978433568 2 1 0 1 1978433568 2 1978433568 1 1978433568 2 1978433568 2 1978433568 1
output:
877694080 -1 -1 877694080 -1 0 877694080 -1 1 877694080 0 -1 877694080 1 -1 877694081 0 1
result:
ok #experiments: 5
Test #3:
score: 3
Accepted
time: 0ms
memory: 3856kb
input:
1978433568 2 1 0 1 1978433568 2 1978433568 2 1978433568 1 1978433568 1 1978433568 2
output:
877694080 -1 -1 877694080 -1 0 877694080 -1 1 877694080 0 -1 877694080 1 -1 877694081 1 0
result:
ok #experiments: 5
Test #4:
score: 1.5
Acceptable Answer
time: 0ms
memory: 3904kb
input:
1978433568 2 1 0 1 1978433568 1 1978433568 1 1978433568 1 1978433568 1 1978433568 1
output:
877694080 -1 -1 877694080 0 0 877694080 1 1 877694080 -1 -1 877694080 -1 -1 877694081 0 0
result:
points 0.50 points 0.5
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
50%
Acceptable Answer
Test #5:
score: 3.5
Acceptable Answer
time: 0ms
memory: 4148kb
input:
1978433568 50 49 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 19784335...
output:
877694080 -1 -1 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 877694080 50 -1 -1 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 5...
result:
points 0.50 points 0.5
Test #6:
score: 0
Wrong Answer
time: 1ms
memory: 3872kb
input:
1978433568 49 48 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 1978433568 2 1...
output:
877694080 -1 -1 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 877694080 49 -1 -1 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 4...
result:
wrong answer Vertices 8 and 9 do not have the same color, but they do in returned answer
Subtask #3:
score: 0
Wrong Answer
Test #34:
score: 0
Wrong Answer
time: 9ms
memory: 3844kb
input:
1978433568 250 249 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 ...
output:
877694080 -1 -1 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 ...
result:
wrong answer Vertices 146 and 147 do not have the same color, but they do in returned answer
Subtask #4:
score: 0
Wrong Answer
Test #43:
score: 0
Wrong Answer
time: 69ms
memory: 4628kb
input:
1978433568 250 31125 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 32 0 33 0 34 0 35 0 36 0 37 0 38 0 39 0 40 0 41 0 42 0 43 0 44 0 45 0 46 0 47 0 48 0 49 0 50 0 51 0 52 0 53 0 54 0 55 0 56 0 57 0 5...
output:
877694080 -1 -1 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 ...
result:
wrong answer Vertices 0 and 1 do not have the same color, but they do in returned answer
Subtask #5:
score: 0
Skipped
Dependency #1:
50%
Acceptable Answer
Dependency #2:
0%