-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path644.cpp
53 lines (46 loc) · 1.23 KB
/
644.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <string>
using namespace std;
int main(void)
{
int T = 0, st;
bool dup;
size_t size = 100;
char * buf = (char *)malloc(sizeof(char) * size);
map<string, int> check;
st = 0;
while (1) {
dup = false;
check.clear();
while (1) {
st = getline(&buf, &size, stdin);
if (buf[0] == '9') break;
if (!dup) {
buf[strlen(buf) - 1] = '\0';
if (check[string(buf)]) {
dup = true;
}
else {
check[string(buf)] = 1;
for (int i = strlen(buf) - 1; i > 0; --i) {
buf[i] = '\0';
if (check[string(buf)] == 1) {
dup = true;
break;
}
check[string(buf)] = 2;
}
}
}
}
if (st == -1) break;
if (dup)
printf("Set %d is not immediately decodable\n", ++T);
else
printf("Set %d is immediately decodable\n", ++T);
}
return 0;
}