QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#357406 | #403. Memory2 | bonkar | 100 ✓ | 1ms | 3860kb | C++14 | 2.2kb | 2024-03-18 21:03:54 | 2024-03-18 21:03:54 |
Judging History
answer
#include "Memory2_lib.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
constexpr int MAXN = 101;
int usd[MAXN];
int wst[MAXN];
int res[MAXN];
vector<int> rr[MAXN];
void Solve(int T, int n){
n*=2;
for(int i = 0; i < n; i++){
res[i] = -1;
}
int a=0, b=1, c=-1, r=Flip(0, 1);
for(int i = 2; i < n; i++){
//cerr << i << " : " << a << ' ' << b << ' ' << c << ' ' << r << '\n';
int r2 = Flip(a, i);
int r3 = Flip(b, i);
//cerr << r2 << ' ' << r3 << '\n';
if(c != -1){
if(r2 == r3){
if(r2 == r){
//There were two, and we approved a and b
res[a] = r;
res[b] = r;
a = c;
b = i;
c = -1;
r = Flip(a, b);
continue;
}
else{
res[i] = r2;
continue;
}
}
else if(r == r2){
swap(a, b);
swap(r2, r3);
}
//r = r3 <=> r2(a) is NOT in pair <=> b and c are the pair
res[b] = r;
res[c] = r;
b = i;
c = -1;
r = Flip(a, b);
continue;
}
if(r == r2 && r2 == r3){
//Two of same kind
//WE discovered two of same kind
c = a;
a = i;
r = r3;
continue;
}
else{
if(r == r2){
res[a] = r;
a = i;
r = r3;
}
else if(r == r3){
res[b] = r;
b = i;
r = r2;
}
else if(r2 == r3){
res[i] = r2;
}
else{
assert(0);
}
}
}
for(int i = 0; i < n; i++){
//cerr << res[i] << ' ';
if(res[i] != -1)
rr[res[i]].push_back(i);
}
res[a] = r;
res[b] = r;
//cerr << '\n';
//cerr << a << ' ' << b << ' ' << c << ' ' << r << '\n';
int A=-1, B=-1;
for(int i = 0; i*2 < n; i++){
if(rr[i].size() == 0){
res[a] = i;
res[b] = i;
rr[i].push_back(a);
rr[i].push_back(b);
}
else if(rr[i].size() <= 1){
swap(A, B);
A=i;
}
}
if(B != -1){
//Test if a is A
int inv = A + B - r;
int r1 = Flip(a, rr[inv][0]);
// int r2 = Flip(b, rr[r][0]);
if(r1 == r){
swap(a, b);
}
//teraz r2 = r <=> b jest inv a jest r
rr[r].push_back(a);
rr[inv].push_back(inv);
}
for(int i = 0; i < n; i++){
if(rr[i].size() > 1)
Answer(rr[i][0], rr[i][1], i);
}
return;
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 1ms
memory: 3820kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3800kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3808kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3780kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 3732kb
Test #6:
score: 0
Accepted
time: 0ms
memory: 3728kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 3812kb
Test #8:
score: 0
Accepted
time: 1ms
memory: 3740kb
Subtask #2:
score: 50
Accepted
Test #9:
score: 50
Accepted
time: 1ms
memory: 3780kb
Test #10:
score: 0
Accepted
time: 0ms
memory: 3828kb
Test #11:
score: 0
Accepted
time: 1ms
memory: 3820kb
Test #12:
score: 0
Accepted
time: 0ms
memory: 3800kb
Test #13:
score: 0
Accepted
time: 0ms
memory: 3780kb
Test #14:
score: 0
Accepted
time: 0ms
memory: 3720kb
Test #15:
score: 0
Accepted
time: 1ms
memory: 3780kb
Test #16:
score: 0
Accepted
time: 0ms
memory: 3844kb
Test #17:
score: 0
Accepted
time: 1ms
memory: 3804kb
Test #18:
score: 0
Accepted
time: 0ms
memory: 3820kb
Subtask #3:
score: 40
Accepted
Test #19:
score: 40
Accepted
time: 0ms
memory: 3732kb
Test #20:
score: 0
Accepted
time: 0ms
memory: 3780kb
Test #21:
score: 0
Accepted
time: 0ms
memory: 3860kb
Test #22:
score: 0
Accepted
time: 1ms
memory: 3856kb
Test #23:
score: 0
Accepted
time: 0ms
memory: 3816kb
Test #24:
score: 0
Accepted
time: 0ms
memory: 3848kb
Test #25:
score: 0
Accepted
time: 0ms
memory: 3720kb
Test #26:
score: 0
Accepted
time: 0ms
memory: 3836kb
Test #27:
score: 0
Accepted
time: 0ms
memory: 3780kb
Test #28:
score: 0
Accepted
time: 1ms
memory: 3732kb
Extra Test:
score: 0
Extra Test Passed