QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#606211#6809. Code With No Forcesbessie_goes_mooWA 3ms6404kbC++171.9kb2024-10-02 23:18:452024-10-02 23:18:46

Judging History

你现在查看的是最新测评结果

  • [2024-10-02 23:18:46]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:6404kb
  • [2024-10-02 23:18:45]
  • 提交

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++){
        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;
        }
    }
    --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;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 6252kb

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: 6404kb

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: 4884kb

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: 4832kb

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:

1061109567
0 

result:

wrong answer Integer parameter [name=|S|] equals to 1061109567, violates the range [1, 21]