QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#138074 | #6341. The Last Battle | jajco | 0 | 43ms | 3748kb | C++17 | 7.0kb | 2023-08-10 22:00:47 | 2023-08-10 22:00:50 |
Judging History
Anna
#pragma GCC optimize("O3")
#include <vector>
#include <cassert>
#include <string>
#define REP(i, n) for (int i=0; i<(n); ++i)
#define V std::vector
typedef long long ll;
typedef V <int> vi;
typedef V <ll> vll;
typedef V <bool> vb;
struct pkt{
int x,y;
};
void Agenz(vi &sid, V <vi> &odl, V <pkt> &spoz, V <V <pkt>> &sejfy){
static bool czy=0;
if (czy)
return;
czy=1;
int sbit=8;
odl.resize(1<<sbit, vi(1<<sbit, 1e9));
{
int fm=1<<sbit;
for (int i=0; i<fm; ++i){
odl[i][i]=0;
for (int j=1; j<fm; j<<=1){
int ni=i^j;
odl[i][ni]=1;
for (int j2=j<<1; j2<fm; j2<<=1)
odl[i][ni^j2]=1;
}
}
for (int k=0; k<fm; ++k)
for (int i=0; i<fm; ++i)
for (int j=0; j<fm; ++j)
odl[i][j]=std::min(odl[i][j],
odl[i][k]+odl[k][j]);
sid={0, 31, 227};
/*for (int k=0; k<fm; ++k)
for (int i=0; i<fm; ++i){
if (odl[k][i]<=2)
continue;
for (int j=0; j<fm; ++j){
if (odl[k][j]<=2||odl[i][j]<=2)
continue;
sid={k, i, j};
printf("%d %d %d\n", k, i, j);
goto brk1;
}
}*/
brk1:
;
}
spoz={{6, 0}, {7, 1}};
{
pkt xd={0, 2};
while (xd.y<8){
spoz.push_back(xd);
++xd.x,++xd.y;
}
}
sejfy.resize(3, V <pkt>());
{
auto prostokat=[&](int xp, int xk, int yp, int yk){
std::vector <pkt> r;
for (int x=xp; x<=xk; ++x)
for (int y=yp; y<=yk; ++y)
r.push_back({x, y});
return r;
};
sejfy[0]=prostokat(0, 2, 6, 7);
sejfy[1]=prostokat(5, 7, 4, 5);
sejfy[2]=prostokat(3, 4, 0, 2);
}
}
#include "Anna.h"
void Anna(int X, int Y, int N, std::string S){
while (S.size()<49)
S+='A';
auto czypokr=[&](const V <pkt> &v, int x, int y){
for (const auto &i : v)
if (i.x==x||i.y==y)
return 1;
return 0;
};
auto enc=[&](int i, int len){
vb r;
for (int j=1; j<(1<<len); j<<=1)
r.push_back(bool(i&j));
return r;
};
auto dec=[&](const vb &i){
int r=0;
for (int j=1,p=0; j<8; j<<=1,++p)
if (i[p])
r+=j;
return r;
};
V <vb> czy(8, vb(8, 0));
for (int i=0; i<8; ++i)
czy[X][i]=czy[i][Y]=1;
static vi sid; static V <vi> odl; static V <pkt> spoz;
static V <V <pkt>> sejfy;
Agenz(sid, odl, spoz, sejfy);
int snum=-1;
for (int i=0; i<3; ++i)
if (!czypokr(sejfy[i], X, Y)){
snum=i;
break;
}
{ // redundantne na snum enc.
vb buf=enc(sid[snum], 8);
int cnt=0;
for (const auto &i : spoz)
if (!czy[i.x][i.y])
Paint(i.x, i.y, buf[cnt++]),czy[i.x][i.y]=1;
}
{ // sejf
vb buf=enc(X+8*Y, 6);
int cnt=0;
for (const auto &i : sejfy[snum]){
assert(!czy[i.x][i.y]);
Paint(i.x, i.y, buf[cnt++]),czy[i.x][i.y]=1;
}
}
{ // reszta czyli S
int cnt=0;
for (int x=0; x<8; ++x)
for (int y=0; y<8; ++y)
if (!czy[x][y])
Paint(x, y, S[cnt++]-'A');
}
}
Bruno
#include <vector>
#include <cassert>
#include <string>
#define REP(i, n) for (int i=0; i<(n); ++i)
#define V std::vector
typedef long long ll;
typedef V <int> vi;
typedef V <ll> vll;
typedef V <bool> vb;
struct pkt{
int x,y;
};
void Bgenz(vi &sid, V <vi> &odl, V <pkt> &spoz, V <V <pkt>> &sejfy){
static bool czy=0;
if (czy)
return;
czy=1;
int sbit=8;
odl.resize(1<<sbit, vi(1<<sbit, 1e9));
{
int fm=1<<sbit;
for (int i=0; i<fm; ++i){
odl[i][i]=0;
for (int j=1; j<fm; j<<=1){
int ni=i^j;
odl[i][ni]=1;
for (int j2=j<<1; j2<fm; j2<<=1)
odl[i][ni^j2]=1;
}
}
for (int k=0; k<fm; ++k)
for (int i=0; i<fm; ++i)
for (int j=0; j<fm; ++j)
odl[i][j]=std::min(odl[i][j],
odl[i][k]+odl[k][j]);
sid={0, 31, 227};/*
for (int k=0; k<fm; ++k)
for (int i=0; i<fm; ++i){
if (odl[k][i]<=2)
continue;
for (int j=0; j<fm; ++j){
if (odl[k][j]<=2||odl[i][j]<=2)
continue;
sid={k, i, j};
goto brk1;
}
}*/
brk1:
;
}
spoz={{6, 0}, {7, 1}};
{
pkt xd={0, 2};
while (xd.y<8){
spoz.push_back(xd);
++xd.x,++xd.y;
}
}
sejfy.resize(3, V <pkt>());
{
auto prostokat=[&](int xp, int xk, int yp, int yk){
std::vector <pkt> r;
for (int x=xp; x<=xk; ++x)
for (int y=yp; y<=yk; ++y)
r.push_back({x, y});
return r;
};
sejfy[0]=prostokat(0, 2, 6, 7);
sejfy[1]=prostokat(5, 7, 4, 5);
sejfy[2]=prostokat(3, 4, 0, 2);
}
}
#include "Bruno.h"
std::string Bruno(int N, std::vector <std::vector <int>> T){
auto czypokr=[&](const V <pkt> &v, int x, int y){
for (const auto &i : v)
if (i.x==x||i.y==y)
return 1;
return 0;
};
auto enc=[&](int i, int len){
vb r;
for (int j=1; j<(1<<len); j<<=1)
r.push_back(bool(i&j));
return r;
};
auto dec=[&](const vb &i){
int r=0;
for (int j=1,p=0; j<8; j<<=1,++p)
if (i[p])
r+=j;
return r;
};
V <vb> czy(8, vb(8, 0));
static vi sid; static V <vi> odl; static V <pkt> spoz;
static V <V <pkt>> sejfy;
Bgenz(sid, odl, spoz, sejfy);
int snum=-1;
{ // redundantne na snum enc.
vb buf;
for (const auto &i : spoz){
assert(!czy[i.x][i.y]);
buf.push_back(T[i.x][i.y]);
czy[i.x][i.y]=1;
}
int tmp=dec(buf);
int cnt=0;
for (int i : sid){
if (odl[tmp][i]<2){
assert(snum<0);
snum=cnt;
}
++cnt;
}
}
int X,Y;
{ // sejf
vb buf;
int cnt=0;
for (const auto &i : sejfy[snum]){
assert(!czy[i.x][i.y]);
buf.push_back(T[i.x][i.y]);
czy[i.x][i.y]=1;
}
int tmp=dec(buf);
X=tmp%8,Y=tmp/8;
}
for (int i=0; i<8; ++i)
czy[X][i]=czy[i][Y]=1;
// reszta czyli S
std::string r;
for (int x=0; x<8; ++x)
for (int y=0; y<8; ++y)
if (!czy[x][y]&&int(r.size())<N)
r+=T[x][y] ? 'B' : 'A';
return r;
}
详细
Test #1:
score: 0
Wrong Answer
time: 43ms
memory: 3748kb
Manager to Anna
20000 1 7 1 A 2 3 1 A 0 1 1 A 1 1 1 A 7 4 1 A 2 3 1 A 0 3 1 B 0 7 1 A 4 2 1 B 5 4 1 A 6 0 1 B 7 3 1 A 0 7 1 A 2 3 1 A 1 6 1 A 5 2 1 B 2 7 1 B 6 3 1 A 3 3 1 A 1 7 1 A 2 3 1 A 1 2 1 A 5 3 1 A 3 5 1 A 4 3 1 A 2 3 1 A 4 6 1 B 7 3 1 B 2 3 1 A 4 4 1 A 7 3 1 A 4 5 1 B 0 7 1 A 0 3 1 B 2 0 1 B 4 1 1 A 6 0 1 ...
Anna to Manager
0010000000010000000100000000000010010000100100110 0010000000000000001000000010000010010001000101000 0010000000100000001000000010000000010001000000000 0100000000100000001000000010000100010001000000000 0000011000001000000010000000000000000000000000000 0010000000000000001000000010000010010001000101000 ...
Manager to Bruno
20000 1 0010000110010100000010000000010000000001000010001000010101001100 1 0011000000000000000011000001010000010010000101001000010001011000 1 1101011101010000000010000100010000000010010000001100010001000000 1 0110000000000001000010000000010000000010010010001000010000000000 1 000010110000101000000001...
Bruno to Manager
A A B A A A A A A A B A B A A A A A A A A B A A A A A A A A A A A A B B B A A A A A B A A A A A A A A A A A A A A A A A A A A B A B A A A A A A A A A A A A A A A B A A A A B A A A A A A A B A A A A A A A B A A A A A A A A A A A A A A A B A A A A B A A A A A A A A A A A A A B A A A B A A A A A A A B ...
result:
points 0.0 Accepted: 0