forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathI.cpp
More file actions
62 lines (57 loc) · 1.19 KB
/
I.cpp
File metadata and controls
62 lines (57 loc) · 1.19 KB
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
54
55
56
57
58
59
60
61
62
#include <bits/stdc++.h>
using namespace std;
int n, col[22222], id[6666];
vector <int> b[6666];
int isGood(int i)
{
int sum = 0;
for (auto j : b[i])
sum += col[j] - 1;
return sum > n * (n / 2 - 1);
}
int isGood(int u, int v)
{
int intersect = 0;
for (int i = 0, j = 0; i < b[u].size() && j < b[v].size();)
if (b[u][i] == b[v][j])
{
intersect++;
i++;
j++;
}
else if (b[u][i] < b[v][j]) i++;
else j++;
return intersect >= n / 2;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
string s;
cin >> n;
for (int i = 1; i <= n + 1; i++)
{
cin >> s;
id[i] = i;
for (int p = 0; p < s.size(); p++)
for (int q = 0; q < 6; q++)
{
int j = p * 6 + q;
if (j < n * 2 && ((s[p] - 33) >> q & 1))
{
col[j]++;
b[i].push_back(j);
}
}
cout << endl;
}
random_shuffle(id + 1, id + n + 2);
for (int i = 1; i <= n + 1; i++)
if (isGood(id[i]))
for (int j = 1; j <= n + 1; j++)
if (i != j && isGood(id[i], id[j]))
{
cout << id[i] << ' ' << id[j] << endl;
return 0;
}
}