QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#606218 | #6809. Code With No Forces | bessie_goes_moo | WA | 3ms | 6444kb | C++17 | 2.0kb | 2024-10-02 23:26:49 | 2024-10-02 23:26:56 |
Judging History
answer
#include<iostream>
#include<cstring>
using namespace std;
const int N=405,M=6+1,MS=1<<18|5;
int read(){
int red=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){ if(ch=='-') f=-f;ch=getchar();}
while(ch>='0'&&ch<='9') red=red*10+ch-48,ch=getchar();
return red*f;
}
char getch(){
char ch=getchar();
while(ch<'A'||ch>'Z') ch=getchar();
return ch;
}
int n,m,time_[N][M],memory[N][M],result_time[M],result_memory[M];
int w1[N],w2[N],ans[N];
int f[MS],from_S[MS],from_N[MS];
char output[N][M],result[M];
int main(){
n=read(),m=read();
for(int i=1;i<=n;i++)
for(int j=0;j<m;j++){
output[i][j]=getch();
time_[i][j]=read(),memory[i][j]=read();
if(!result[j]){
result_time[j]=max(result_time[j],time_[i][j]);
result_memory[j]=max(result_memory[j],memory[i][j]);
if(output[i][j]!='O') result[j]=output[i][j];
}
}
for(int i=1;i<=n;i++)
for(int j=0;j<m;j++){
if(result[j]==output[i][j]) w1[i]|=1<<3*j;else
if(output[i][j]!='O') w2[i]|=1<<3*j;
if(result_time[j]==time_[i][j]) w1[i]|=1<<3*j+1;
if(result_time[j]<time_[i][j]) w2[i]|=1<<3*j+1;
if(result_memory[j]==memory[i][j]) w1[i]|=1<<3*j+2;
if(result_memory[j]<memory[i][j]) w2[i]|=1<<3*j+2;
}
int ts=1<<3*m,OR=0,x=ts;
memset(f,63,sizeof f);f[0]=0;
for(int j=0;j<m;j++) if(!result[j]) OR|=1<<3*j;
for(int s=0;s<ts;s++){
if((OR|s)==ts-1&&f[s]<f[x]) x=s;
bool ok=1;
for(int j=0;j<m;j++) if(s&(1<<3*j)&&(!(s&(1<<3*j+1))||!(s&(1<<3*j+2)))) ok=0;
if(!ok) continue;
for(int i=1;i<=n;i++) if((s&w2[i])==w2[i]){
int ns=s|w1[i];
if(f[s]+1<f[ns]) f[ns]=f[s]+1,from_S[ns]=s,from_N[ns]=i;
}
}
printf("%d\n",f[x]);
while(x){
ans[++ans[0]]=from_N[x];
x=from_S[x];
}
if(!ans[0]) ans[ans[0]=1]=1;
for(int i=ans[0];i;i--) printf("%d ",ans[i]);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 6444kb
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: 1ms
memory: 6056kb
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: 1ms
memory: 4848kb
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: 4992kb
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:
7 9 17 15 13 20 10 12
result:
wrong answer time cost mismatched on file 5