/ /

记录详情

Accepted

foo.cc: In function 'int main()':
foo.cc:80:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&ope[0].t[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~
正在同步测试数据,请稍后
[Hydro](https://hydro.ac)提供评测服务
# 状态 耗时 内存占用
#1 Accepted 73ms 304.0 KiB
#2 Accepted 73ms 280.0 KiB
#3 Accepted 75ms 280.0 KiB
#4 Accepted 77ms 300.0 KiB
#5 Accepted 74ms 276.0 KiB
#6 Accepted 72ms 304.0 KiB
#7 Accepted 72ms 280.0 KiB
#8 Accepted 72ms 304.0 KiB
#9 Accepted 79ms 308.0 KiB
#10 Accepted 78ms 300.0 KiB

代码

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

struct item{
    int t[10];
    bool empty(){
        for(int i=1;i<=9;i++)
            if(t[i])return false;
        return true;
    }
};

struct Queue{
    int t[40],top;
    Queue(){
        memset(t,0,sizeof(t));top=0;
    }
    void push(int x){t[++top]=x;}
    void output(){
        for(int i=1;i<=top;i++)
            printf("%d ",t[i]);
    }
};

bool operator<(Queue A,Queue B){
    if(A.top!=B.top)return A.top<B.top;
    int i;for(i=1;i<=min(A.top,B.top);i++){
        if(A.t[i]!=B.t[i])
            return A.t[i]<B.t[i];
    }
    return A.t[i]<B.t[i];
}

item operator+(item A,item B){
    for(int i=1;i<=9;i++)
        A.t[i]=(A.t[i]+B.t[i])%4;
    return A;
}
item operator*(item A,int time){
    for(int i=1;i<=9;i++)
        A.t[i]=(A.t[i]*time)%4;
    return A;
}

Queue ans;
item ope[12];
int cnt[10];bool suc=0;
void DFS(int step){
    if(step>9){
        item now=ope[0];
        for(int i=1;i<=9;i++)
            now=now+(ope[i]*cnt[i]);
        if(now.empty()){
            if(ans.top==0)
                for(int i=1;i<=9;i++){
                    for(int j=1;j<=cnt[i];j++)
                        ans.push(i);
                }
            else{
                Queue n;n=Queue();
                for(int i=1;i<=9;i++){
                    for(int j=1;j<=cnt[i];j++)
                        n.push(i);
                }
                if(n<ans)ans=n;
            }
        }
        return;
    }
    for(int i=0;i<4;i++){
        cnt[step]=i;
        DFS(step+1);
    }
}
int main(){
    for(int i=1;i<=9;i++)
        scanf("%d",&ope[0].t[i]);
    ope[1]=(item){0,1,1,0,1,1,0,0,0,0};//ABDE 
    ope[2]=(item){0,1,1,1,0,0,0,0,0,0};//ABC  
    ope[3]=(item){0,0,1,1,0,1,1,0,0,0};//BCEF 
    ope[4]=(item){0,1,0,0,1,0,0,1,0,0};//ADG  
    ope[5]=(item){0,0,1,0,1,1,1,0,1,0};//BDEFH
    ope[6]=(item){0,0,0,1,0,0,1,0,0,1};//CFI  
    ope[7]=(item){0,0,0,0,1,1,0,1,1,0};//DEGH 
    ope[8]=(item){0,0,0,0,0,0,0,1,1,1};//GHI  
    ope[9]=(item){0,0,0,0,0,1,1,0,1,1};//EFHI
    DFS(1);
    ans.output();
    return 0;
}

信息

递交者
类型
递交
题目
P1075 北京2008的挂钟
题目数据
下载
语言
C++
递交时间
2021-08-18 14:45:22
评测时间
2021-08-18 14:45:22
评测机
分数
100
总耗时
750ms
峰值内存
308.0 KiB