UVALive - 6269 Digital Clock 模拟
来源:互联网 发布:aegisub mac 闪退 编辑:程序博客网 时间:2024/06/01 09:51
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\n");168 }169 else{170 printf("\n");171 }172 }173 return 0;174 }
0 0
- UVALive - 6269 Digital Clock 模拟
- UVALive 6269 Digital Clock --枚举,模拟
- UvaLive--6664--Clock Hands【模拟】
- zoj 3131 Digital Clock
- ZOJ3131 Digital Clock
- zoj 3131 Digital Clock
- ZOJ 3131 Digital Clock
- QT实现Digital Clock
- UvaLive 6664 Clock Hands
- UVALive 6664 Clock Hands
- Clock Splitter+uvalive+二分
- UVALive 2037 Digital River
- zoj3131 Digital Clock(2)
- 【QT 教程】Digital Clock Example
- Digital Clock 数论水题
- UVa 1529 - Clock (模拟)
- HDU 5387 Clock // 模拟
- HDU5387 Clock 时钟模拟
- POJ - 3847 Moving to Nuremberg 动归
- Aizu - 2555 Everlasting Zero 模拟
- android学习笔记——SQLite简单应用及介绍
- Aizu - 2564 Tree Reconstruction 并查集
- SO_RCVBUF SO_SNDBUF
- UVALive - 6269 Digital Clock 模拟
- UVALive - 6266 Admiral 费用流
- UVALive - 6268 Cycling 贪心
- 集训回顾
- 简单的设计不简单
- Gym - 100338E Numbers 贪心
- markdown test
- div+css布局中积累的经验之一
- Gym - 100338C Important Roads 最短路+tarjan