QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#606253#6809. Code With No Forcesbessie_goes_mooWA 1ms6480kbC++172.0kb2024-10-02 23:53:262024-10-02 23:53:27

Judging History

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

  • [2024-10-02 23:53:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6480kb
  • [2024-10-02 23:53:26]
  • 提交

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],w3[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') w3[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]))&&((s&w3[i])==w3[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: 6408kb

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

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

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: 0ms
memory: 6192kb

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]