• UVALive


     UVALive - 6269 Digital Clock

    题意:时钟坏了,给你一段连续的时间,问你现在可能的时间是多少。

    思路:直接模拟,他妈的居然这场就跪在了这题,卧槽,他妈的就在111行,居然多打了个 = ,这是什么意思,注孤生吗

      1 #pragma comment(linker, "/STACK:1000000000")
      2 #include <bits/stdc++.h>
      3 #define LL long long
      4 #define INF 0x3f3f3f3f
      5 #define IN freopen("d.in","r",stdin);
      6 #define OUT freopen("out.txt","w",stdout);
      7 using namespace std;
      8 #define MAXN 9999
      9 int w[6][10], y[6][10];
     10 bool first;
     11 struct Node{
     12     bool vis[9];
     13     Node(int x){
     14         memset(vis, 0, sizeof(vis));
     15         if(x != 1 && x != 4){
     16             vis[1] = true;
     17         }
     18         if(x != 1 && x != 2 && x != 3 && x != 7){
     19             vis[2] = true;
     20         }
     21         if(x != 5 && x != 6){
     22             vis[3] = true;
     23         }
     24         if(x != 0 && x != 1 && x != 7){
     25             vis[4] = true;
     26         }
     27         if(x == 0 || x == 2 || x == 6 || x == 8){
     28             vis[5] = true;
     29         }
     30         if(x != 2){
     31             vis[6] = true;
     32         }
     33         if(x != 1 && x != 4 && x != 7){
     34             vis[7] = true;
     35         }
     36     }
     37 };
     38 
     39 struct Moment{
     40     int hour, mi;
     41     int u[7];
     42     Moment(int i = 0){
     43         hour = i / 60;
     44         mi = i % 60;
     45         u[0] = hour / 10;
     46         u[1] = hour % 10;
     47         u[3] = mi / 10;
     48         u[4] = mi % 10;
     49     }
     50     void print(){
     51         if(first){
     52             printf("%d%d:%d%d", u[0], u[1], u[3], u[4]);
     53             first = false;
     54         }
     55         else{
     56             printf(" %d%d:%d%d", u[0], u[1], u[3], u[4]);
     57         }
     58     }
     59 };
     60 bool work(char *s, int x){
     61     Moment t = Moment(x);
     62     memset(w, 0, sizeof(w));
     63     for(int i = 0; i < 5; i++){
     64         if(i == 2) continue;
     65         Node p = Node(s[i] - '0');
     66         Node q = Node(t.u[i]);
     67         for(int j = 1; j <= 7; j++){
     68             if(!p.vis[j] && q.vis[j]){
     69                 w[i][j] = 1;
     70                 continue;
     71             }
     72             if(p.vis[j] && !q.vis[j]){
     73                 return false;
     74             }
     75             if(p.vis[j] && q.vis[j]){
     76                 w[i][j] = 2;
     77             }
     78         }
     79     }
     80     return true;
     81 }
     82 
     83 bool work_y(char *s, int x){
     84     Moment t = Moment(x);
     85     memset(y, 0, sizeof(y));
     86     for(int i = 0; i < 5; i++){
     87         if(i == 2) continue;
     88         Node p = Node(s[i] - '0');
     89         Node q = Node(t.u[i]);
     90         for(int j = 1; j <= 7; j++){
     91             if(!p.vis[j] && q.vis[j]){
     92                 y[i][j] = 1;
     93                 continue;
     94             }
     95             if(p.vis[j] && !q.vis[j]){
     96                 return false;
     97             }
     98             if(p.vis[j] && q.vis[j]){
     99                 y[i][j] = 2;
    100             }
    101         }
    102     }
    103     return true;
    104 }
    105 bool check(){
    106     for(int i = 0; i < 5; i++){
    107         if(i == 2) continue;
    108         for(int j = 1; j <= 7; j++){
    109             if(y[i][j] == 0) continue;
    110             if(w[i][j] == 0 && y[i][j] != 0){
    111                 w[i][j] = y[i][j];
    112                 continue;
    113             }
    114             if(w[i][j] == 1 && y[i][j] == 2){
    115                 return false;
    116             }
    117             if(w[i][j] == 2 && y[i][j] == 1){
    118                 return false;
    119             }
    120         }
    121     }
    122     return true;
    123 }
    124 char s[55][10];
    125 int main()
    126 {
    127    //IN;
    128    //OUT;
    129    int n;
    130    int cas = 1;
    131    while(~scanf("%d", &n)){
    132         if(cas == 42){
    133             int o = 1;
    134             o = 1 + 2;
    135         }
    136         cas++;
    137         for(int i = 1; i <= n; i++){
    138             scanf("%s", s[i]);
    139         }
    140         Moment t;
    141         first = true;
    142         for(int i = 0; i < 1440; i++){
    143             if( i == 443){
    144                 int o;
    145                 o =  1 + 2;
    146             }
    147             if(!work(s[1], i)) continue;
    148             bool flag = false;
    149             for(int j = 2; j <= n; j++){
    150                 if(i + j - 1 == 480){
    151                     int o;
    152                     o = 1 + 2;
    153                 }
    154                 if(!work_y(s[j], (i + j - 1) % 1440)){
    155                     flag = true;
    156                     break;
    157                 }
    158                 if(check()) continue;
    159                 flag = true;
    160                 break;
    161             }
    162             if(flag) continue;
    163             t = Moment(i);
    164             t.print();
    165         }
    166         if(first){
    167             printf("none
    ");
    168         }
    169         else{
    170             printf("
    ");
    171         }
    172    }
    173    return 0;
    174 }
  • 相关阅读:
    微信支付开发
    dz插件开发(一) 从常用的常量 变量 函数开始
    收集bootstrap的几个常用用法---tooltip提示框
    ucenter接口
    php防止表单重复提交
    支付宝接口 CI上集成
    telnet模拟post 调试的时候很好用
    __call 实现函数方法不同参数个数的重载
    微赞的分页
    结合微赞发布家和小程序流程
  • 原文地址:https://www.cnblogs.com/macinchang/p/4752740.html
Copyright © 2020-2023  润新知