QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#606204 | #6809. Code With No Forces | bessie_goes_moo | WA | 1ms | 6436kb | C++17 | 1.8kb | 2024-10-02 23:10:53 | 2024-10-02 23:10:53 |
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 j=0;j<m;j++) if(!result[j]) result[j]='O';
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;
memset(f,63,sizeof f);f[0]=0;
for(int s=0;s<ts;s++)
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;
}
--ts;
printf("%d\n",f[ts]);
while(ts){
ans[++ans[0]]=from_N[ts];
ts=from_S[ts];
}
for(int i=ans[0];i;i--) printf("%d ",ans[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 6436kb
input:
2 3 OK,1/1 OK,2/1 OK,2/2 WA,1/1 OK,1/1 TL,1000/1
output:
2 2 1
result:
wrong answer memory mismatched on file 3