QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#306025 | #6809. Code With No Forces | lmeowdn | WA | 3ms | 19112kb | C++14 | 3.0kb | 2024-01-16 10:14:12 | 2024-01-16 10:14:12 |
Judging History
answer
//vanitas vanitatum et omnia vanitas
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
const int N=405,M=(1<<6)+5;
int f[M][M][M],n,m,g[M][M][M],gs[M][M][M],gt[M][M][M],gr[M][M][M],tp[N][N],a[N][N],b[N][N],xa[N],xb[N],y[N];
int trans(char c) {
if(c=='O') return 0;
else if(c=='W') return 1;
else if(c=='M') return 2;
else if(c=='T') return 3;
else return 4;
}
signed main() {
n=read(), m=read();
rep(i,1,n) {
rep(j,1,m) {
char c=getchar(); while(!isalpha(c)) c=getchar();
tp[i][j]=trans(c); a[i][j]=read(), b[i][j]=read();
if(y[j]==0&&tp[i][j]) {
y[j]=tp[i][j]; xa[j]=a[i][j], xb[j]=b[i][j];
} else if(y[j]==0) {
chmax(xa[j],a[i][j]), chmax(xb[j],b[i][j]);
}
}
}
int S=(1<<m)-1;
rep(s,0,S) rep(t,0,S) rep(r,0,S) f[s][t][r]=N;
f[0][0][0]=0;
rep(s,0,S) rep(t,0,S) rep(r,0,S) if(f[s][t][r]!=N) {
rep(i,1,n) {
bool flag=0; int ns=s, nt=t, nr=r;
rep(j,1,m) if(!((ns&(1<<j-1))&&(nt&(1<<j-1))&&(nr&(1<<j-1)))) {
if(a[i][j]==xa[j]) ns|=(1<<j-1);
if(b[i][j]==xb[j]) nt|=(1<<j-1);
if(y[j]==0) nr|=(1<<j-1);
else if(tp[i][j]) {
if(tp[i][j]!=y[j]) flag=1;
else if(!(ns&(1<<j-1))) flag=1;
else if(!(nt&(1<<j-1))) flag=1;
else nr|=(1<<j-1);
}
}
if(flag) continue;
if(chmin(f[ns][nt][nr],f[s][t][r]+1))
g[ns][nt][nr]=i, gs[ns][nt][nr]=s, gt[ns][nt][nr]=t, gr[ns][nt][nr]=r;
}
}
printf("%lld\n",f[S][S][S]);
vi ans; int s=S, t=S, r=S;
rep(i,1,f[S][S][S]) {
ans.eb(g[s][t][r]);
int xs=gs[s][t][r], xt=gt[s][t][r], xr=gr[s][t][r];
s=xs, t=xt, r=xr;
} reverse(ans.begin(),ans.end());
for(int x:ans) printf("%lld ",x); puts("");
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 16040kb
input:
2 3 OK,1/1 OK,2/1 OK,2/2 WA,1/1 OK,1/1 TL,1000/1
output:
2 1 2
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 16136kb
input:
3 3 OK,1/1 OK,2/1 OK,1/2 OK,3/3 OK,1/2 OK,114/514 WA,999/999 TL,3000/2 ML,999/1024
output:
1 3
result:
ok ok
Test #3:
score: 0
Accepted
time: 2ms
memory: 16304kb
input:
5 3 OK,0/0 OK,0/0 OK,0/0 WA,1/0 RE,0/0 OK,0/0 WA,0/0 WA,0/0 WA,0/0 OK,1/0 RE,0/0 OK,0/0 WA,2/2 RE,2/2 WA,2/2
output:
2 4 3
result:
ok ok
Test #4:
score: -100
Wrong Answer
time: 3ms
memory: 19112kb
input:
21 6 OK,0/34 OK,15/1 OK,0/1 OK,0/4 OK,0/1 OK,0/36 OK,0/34 OK,0/1 OK,15/1 OK,15/4 OK,0/1 OK,0/36 OK,0/34 OK,15/1 OK,0/1 OK,0/4 OK,15/1 OK,0/36 OK,0/34 OK,0/1 OK,0/1 OK,0/4 OK,15/1 OK,0/36 OK,0/34 OK,0/1 OK,15/1 OK,0/4 OK,0/1 OK,0/36 OK,0/34 OK,0/1 OK,0/1 OK,0/4 OK,0/1 OK,0/36 OK,0/34 OK,0/1 OK,0/1 OK...
output:
6 15 10 17 20 13 12
result:
wrong answer time cost mismatched on file 3