QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#99657 | #403. Memory2 | lmeowdn | 100 ✓ | 3ms | 3772kb | C++14 | 1.5kb | 2023-04-23 12:09:21 | 2023-04-23 12:09:25 |
Judging History
answer
#include "Memory2_lib.h"
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define fi first
#define se second
#define eb emplace_back
#define popc __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef unsigned long long ull;
typedef long double ld;
const int N=109;
int vst[N],a[N],f[N][N],ans[N],del[N];
pii p[N],g[N],h[N];
int qry(int i,int j) {
if(i>j) swap(i,j);
if(~f[i][j]) return f[i][j];
else return f[i][j]=Flip(i,j);
}
void Solve(int T,int n) {
rep(i,0,2*n-1) rep(j,0,2*n-1) f[i][j]=-1;
rep(i,0,n-1) p[i]=pii(i,i+n);
rep(t,0,n-1) {
rep(i,0,n-1) vst[i]=-1; bool flag=0;
rep(i,0,n-1) if(!del[i]) {
int x=qry(p[i].fi,p[i].se);
if(~vst[x]) {
int xa=g[x].fi, ya=g[x].se;
int xb=p[i].fi, yb=p[i].se;
if(qry(xa,xb)!=x) {
ans[ya]=ans[yb]=x;
p[i]=pii(xa,xb);
} else if(qry(ya,yb)!=x) {
ans[xa]=ans[xb]=x;
p[i]=pii(ya,yb);
} else if(qry(xa,yb)!=x) {
ans[ya]=ans[xb]=x;
p[i]=pii(xa,yb);
} else {
ans[xa]=ans[yb]=x;
p[i]=pii(ya,xb);
}
del[vst[x]]=1; flag=1; break;
}
g[x]=p[i], vst[x]=i;
}
if(!flag) {
rep(i,0,n-1) if(!del[i]) {
int x=p[i].fi, y=p[i].se, f=qry(x,y);
ans[x]=ans[y]=f;
}
break;
}
}
rep(i,0,2*n-1) {
if(!h[ans[i]].fi) h[ans[i]].fi=i;
else h[ans[i]].se=i;
}
rep(i,0,n-1) Answer(h[i].fi,h[i].se,i);
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 2ms
memory: 3548kb
Test #2:
score: 0
Accepted
time: 2ms
memory: 3532kb
Test #3:
score: 0
Accepted
time: 2ms
memory: 3532kb
Test #4:
score: 0
Accepted
time: 1ms
memory: 3756kb
Test #5:
score: 0
Accepted
time: 2ms
memory: 3624kb
Test #6:
score: 0
Accepted
time: 2ms
memory: 3572kb
Test #7:
score: 0
Accepted
time: 2ms
memory: 3716kb
Test #8:
score: 0
Accepted
time: 2ms
memory: 3656kb
Subtask #2:
score: 50
Accepted
Test #9:
score: 50
Accepted
time: 2ms
memory: 3656kb
Test #10:
score: 0
Accepted
time: 2ms
memory: 3764kb
Test #11:
score: 0
Accepted
time: 2ms
memory: 3616kb
Test #12:
score: 0
Accepted
time: 2ms
memory: 3564kb
Test #13:
score: 0
Accepted
time: 0ms
memory: 3772kb
Test #14:
score: 0
Accepted
time: 2ms
memory: 3500kb
Test #15:
score: 0
Accepted
time: 3ms
memory: 3528kb
Test #16:
score: 0
Accepted
time: 1ms
memory: 3520kb
Test #17:
score: 0
Accepted
time: 1ms
memory: 3652kb
Test #18:
score: 0
Accepted
time: 0ms
memory: 3616kb
Subtask #3:
score: 40
Accepted
Test #19:
score: 40
Accepted
time: 2ms
memory: 3664kb
Test #20:
score: 0
Accepted
time: 2ms
memory: 3652kb
Test #21:
score: 0
Accepted
time: 2ms
memory: 3760kb
Test #22:
score: 0
Accepted
time: 2ms
memory: 3536kb
Test #23:
score: 0
Accepted
time: 0ms
memory: 3532kb
Test #24:
score: 0
Accepted
time: 2ms
memory: 3772kb
Test #25:
score: 0
Accepted
time: 2ms
memory: 3616kb
Test #26:
score: 0
Accepted
time: 1ms
memory: 3652kb
Test #27:
score: 0
Accepted
time: 2ms
memory: 3540kb
Test #28:
score: 0
Accepted
time: 2ms
memory: 3572kb
Extra Test:
score: 0
Extra Test Passed