#include <algorithm>
#include <iostream>
long long trios[1000005];
long long xis[1000005];
long long yis[1000005];
int subt4[1000005];
char answer[1000005];
char potentialans[20];
char happy[20];
int ac[20];
using namespace std;
long long const mult = 1000007;//10^6 + 7
long long inde(long long a, long long b, long long x, long long y)
{
b=0;
return (x-1)*a+y+b-1;//yeah b isn't really needed after all
}
int main()
{
int n;
cin >> n;
if (n==3)
{
int a, b, c, d, e, f;
cin >> a >> d >> b >> e >> c >> f;
if (a==b and b==c)
{
if (d>e and e>f)
{
cout << "101";
}
else if (d<e and e<f)
{
cout << "101";
}
else if (e>d and d>f)
{
cout << "011";
}
else if (e<d and d<f)
{
cout << "011";
}
else if (d>f and f>e)
{
cout << "110";
}
else if (d<f and f<e)
{
cout << "110";
}
}
else if (d==e and e==f)
{
if (a>b and b>c)
{
cout << "101";
}
else if (a<b and b<c)
{
cout << "101";
}
else if (b>a and a>c)
{
cout << "011";
}
else if (b<a and a<c)
{
cout << "011";
}
else if (a>c and c>b)
{
cout << "110";
}
else if (a<c and c<b)
{
cout << "110";
}
}
else
{
cout << "111";
}
cout << '\n';
}
else if (n<=2)
{
if (n==2)
{
cout << "1";
}
cout << "1\n";
}
else if (n<=16)
{
//consider each possibility: tower on tower off
//check ff: at most 2 towers per column/row, all towers are good
for (int i=0; i<n; i++)
{
cin >> xis[i] >> yis[i];
}
for (int i=0; i<(1<<n); i++)
{
int k=i;
ac[n]=1;
for (int j=0; j<n; j++)
{
if (k>=(1<<(n-1-j)))
{
k-=(1<<(n-1-j));
potentialans[j]='1';
ac[j]=1;
}
else
{
potentialans[j]='0';
ac[j]=0;
}
}
for (int j=0; j<n; j++)
{
for (int k=j+1; k<n; k++)
{
for (int l=k+1; l<n; l++)
{
if (xis[j]==xis[k] and xis[k]==xis[l])
{
if (potentialans[j]=='1' and potentialans[k]=='1' and potentialans[l]=='1')
ac[n]=0;
if (yis[j]>yis[k] and yis[j]<yis[l] and potentialans[k]=='1' and potentialans[l]=='1')
{
ac[j]=1;
}
if (yis[j]>yis[l] and yis[j]<yis[k] and potentialans[k]=='1' and potentialans[l]=='1')
{
ac[j]=1;
}
if (yis[k]>yis[j] and yis[k]<yis[l] and potentialans[j]=='1' and potentialans[l]=='1')
{
ac[k]=1;
}
if (yis[k]>yis[l] and yis[k]<yis[j] and potentialans[j]=='1' and potentialans[l]=='1')
{
ac[k]=1;
}
if (yis[l]>yis[j] and yis[l]<yis[k] and potentialans[k]=='1' and potentialans[j]=='1')
{
ac[l]=1;
}
if (yis[l]>yis[k] and yis[l]<yis[j] and potentialans[k]=='1' and potentialans[j]=='1')
{
ac[l]=1;
}
}
else if (yis[j]==yis[k] and yis[k]==yis[l])
{
if (potentialans[j]=='1' and potentialans[k]=='1' and potentialans[l]=='1')
ac[n]=0;
if (xis[j]>xis[k] and xis[j]<xis[l] and potentialans[k]=='1' and potentialans[l]=='1')
{
ac[j]=1;
}
if (xis[j]>xis[l] and xis[j]<xis[k] and potentialans[k]=='1' and potentialans[l]=='1')
{
ac[j]=1;
}
if (xis[k]>xis[j] and xis[k]<xis[l] and potentialans[j]=='1' and potentialans[l]=='1')
{
ac[k]=1;
}
if (xis[k]>xis[l] and xis[k]<xis[j] and potentialans[j]=='1' and potentialans[l]=='1')
{
ac[k]=1;
}
if (xis[l]>xis[j] and xis[l]<xis[k] and potentialans[k]=='1' and potentialans[j]=='1')
{
ac[l]=1;
}
if (xis[l]>xis[k] and xis[l]<xis[j] and potentialans[k]=='1' and potentialans[j]=='1')
{
ac[l]=1;
}
}
}
}
}
int totall=0;
for (int j=0; j<=n; j++)
{
totall=totall+ac[j];
}
if (totall==n+1)
{
cout << potentialans << '\n';
for (int i=0; i<n; i++)
happy[i]=potentialans[i];
}
}
//cout << happy << '\n';
}
else
{
int four=1;
long long b=0;
long long a=0;
for (int i=0; i<n; i++)
{
cin >> xis[i] >> yis[i];
b=max(b, xis[i]);
a=max(a, yis[i]);
trios[i]=mult*mult*yis[i]+mult*xis[i]+i;
subt4[xis[i]]++;
if (subt4[xis[i]]>=3)
four=0;
}
if (four)
{
for (int i=0; i<n; i++)
{
answer[i]='1';
}
sort(trios, trios+n);
int sindex=0;
int eindex=0;
while (sindex<n)
{
while (trios[eindex]/(mult*mult) == trios[eindex+1]/(mult*mult))
{
eindex++;
}
for (int i=sindex+1; i<eindex; i++)
{
answer[trios[i]%mult] = '0';
}
sindex=eindex+1;
eindex=sindex+1-1;
}
cout << answer << '\n';
}
else
{
//assume this is subtask 3, then we already have our values of b and a
for (int i=0; i<n; i++)
{
answer[i]='0';
}
if (a==b)
{
for (int i=1; i<=a; i++)
{
answer[inde(a, b, i, i)]='1';
answer[inde(a, b, i, a+1-i)]='1';
}
}
else if (a>b)
{
for (long long i=1; i<=b; i++)
{
answer[inde(a, b, i, min(i, b+1-i))]='1';
answer[inde(a, b, i, a+1-min(i, b+1-i))]='1';
}
}
else
{
for (long long i=1; i<=a; i++)
{
answer[inde(a, b, min(i, a+1-i), i)]='1';
answer[inde(a, b, b+1-min(i, a+1-i), i)]='1';
}
}
cout << answer << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
284 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
284 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
81 ms |
304 KB |
Output is correct |
12 |
Correct |
89 ms |
212 KB |
Output is correct |
13 |
Correct |
75 ms |
300 KB |
Output is correct |
14 |
Correct |
78 ms |
212 KB |
Output is correct |
15 |
Correct |
79 ms |
304 KB |
Output is correct |
16 |
Correct |
84 ms |
212 KB |
Output is correct |
17 |
Correct |
98 ms |
308 KB |
Output is correct |
18 |
Correct |
87 ms |
300 KB |
Output is correct |
19 |
Correct |
94 ms |
300 KB |
Output is correct |
20 |
Correct |
92 ms |
304 KB |
Output is correct |
21 |
Correct |
93 ms |
300 KB |
Output is correct |
22 |
Correct |
97 ms |
300 KB |
Output is correct |
23 |
Correct |
97 ms |
300 KB |
Output is correct |
24 |
Correct |
85 ms |
300 KB |
Output is correct |
25 |
Correct |
86 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
2560 KB |
Output is correct |
2 |
Correct |
46 ms |
3156 KB |
Output is correct |
3 |
Correct |
129 ms |
8976 KB |
Output is correct |
4 |
Correct |
264 ms |
17328 KB |
Output is correct |
5 |
Correct |
45 ms |
3324 KB |
Output is correct |
6 |
Correct |
8 ms |
852 KB |
Output is correct |
7 |
Correct |
241 ms |
16280 KB |
Output is correct |
8 |
Correct |
156 ms |
10956 KB |
Output is correct |
9 |
Correct |
408 ms |
24056 KB |
Output is correct |
10 |
Correct |
337 ms |
20444 KB |
Output is correct |
11 |
Correct |
370 ms |
25720 KB |
Output is correct |
12 |
Correct |
376 ms |
25672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
608 ms |
29720 KB |
Output is correct |
2 |
Correct |
646 ms |
29572 KB |
Output is correct |
3 |
Correct |
639 ms |
29548 KB |
Output is correct |
4 |
Correct |
618 ms |
29552 KB |
Output is correct |
5 |
Correct |
621 ms |
29608 KB |
Output is correct |
6 |
Correct |
635 ms |
29644 KB |
Output is correct |
7 |
Correct |
664 ms |
29544 KB |
Output is correct |
8 |
Correct |
625 ms |
29720 KB |
Output is correct |
9 |
Correct |
647 ms |
29588 KB |
Output is correct |
10 |
Correct |
624 ms |
29576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
284 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
81 ms |
304 KB |
Output is correct |
12 |
Correct |
89 ms |
212 KB |
Output is correct |
13 |
Correct |
75 ms |
300 KB |
Output is correct |
14 |
Correct |
78 ms |
212 KB |
Output is correct |
15 |
Correct |
79 ms |
304 KB |
Output is correct |
16 |
Correct |
84 ms |
212 KB |
Output is correct |
17 |
Correct |
98 ms |
308 KB |
Output is correct |
18 |
Correct |
87 ms |
300 KB |
Output is correct |
19 |
Correct |
94 ms |
300 KB |
Output is correct |
20 |
Correct |
92 ms |
304 KB |
Output is correct |
21 |
Correct |
93 ms |
300 KB |
Output is correct |
22 |
Correct |
97 ms |
300 KB |
Output is correct |
23 |
Correct |
97 ms |
300 KB |
Output is correct |
24 |
Correct |
85 ms |
300 KB |
Output is correct |
25 |
Correct |
86 ms |
296 KB |
Output is correct |
26 |
Correct |
5 ms |
4268 KB |
Output is correct |
27 |
Correct |
6 ms |
4232 KB |
Output is correct |
28 |
Runtime error |
10 ms |
5844 KB |
Execution killed with signal 11 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
284 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
81 ms |
304 KB |
Output is correct |
12 |
Correct |
89 ms |
212 KB |
Output is correct |
13 |
Correct |
75 ms |
300 KB |
Output is correct |
14 |
Correct |
78 ms |
212 KB |
Output is correct |
15 |
Correct |
79 ms |
304 KB |
Output is correct |
16 |
Correct |
84 ms |
212 KB |
Output is correct |
17 |
Correct |
98 ms |
308 KB |
Output is correct |
18 |
Correct |
87 ms |
300 KB |
Output is correct |
19 |
Correct |
94 ms |
300 KB |
Output is correct |
20 |
Correct |
92 ms |
304 KB |
Output is correct |
21 |
Correct |
93 ms |
300 KB |
Output is correct |
22 |
Correct |
97 ms |
300 KB |
Output is correct |
23 |
Correct |
97 ms |
300 KB |
Output is correct |
24 |
Correct |
85 ms |
300 KB |
Output is correct |
25 |
Correct |
86 ms |
296 KB |
Output is correct |
26 |
Correct |
5 ms |
4268 KB |
Output is correct |
27 |
Correct |
6 ms |
4232 KB |
Output is correct |
28 |
Runtime error |
10 ms |
5844 KB |
Execution killed with signal 11 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
284 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
81 ms |
304 KB |
Output is correct |
12 |
Correct |
89 ms |
212 KB |
Output is correct |
13 |
Correct |
75 ms |
300 KB |
Output is correct |
14 |
Correct |
78 ms |
212 KB |
Output is correct |
15 |
Correct |
79 ms |
304 KB |
Output is correct |
16 |
Correct |
84 ms |
212 KB |
Output is correct |
17 |
Correct |
98 ms |
308 KB |
Output is correct |
18 |
Correct |
87 ms |
300 KB |
Output is correct |
19 |
Correct |
94 ms |
300 KB |
Output is correct |
20 |
Correct |
92 ms |
304 KB |
Output is correct |
21 |
Correct |
93 ms |
300 KB |
Output is correct |
22 |
Correct |
97 ms |
300 KB |
Output is correct |
23 |
Correct |
97 ms |
300 KB |
Output is correct |
24 |
Correct |
85 ms |
300 KB |
Output is correct |
25 |
Correct |
86 ms |
296 KB |
Output is correct |
26 |
Correct |
34 ms |
2560 KB |
Output is correct |
27 |
Correct |
46 ms |
3156 KB |
Output is correct |
28 |
Correct |
129 ms |
8976 KB |
Output is correct |
29 |
Correct |
264 ms |
17328 KB |
Output is correct |
30 |
Correct |
45 ms |
3324 KB |
Output is correct |
31 |
Correct |
8 ms |
852 KB |
Output is correct |
32 |
Correct |
241 ms |
16280 KB |
Output is correct |
33 |
Correct |
156 ms |
10956 KB |
Output is correct |
34 |
Correct |
408 ms |
24056 KB |
Output is correct |
35 |
Correct |
337 ms |
20444 KB |
Output is correct |
36 |
Correct |
370 ms |
25720 KB |
Output is correct |
37 |
Correct |
376 ms |
25672 KB |
Output is correct |
38 |
Correct |
608 ms |
29720 KB |
Output is correct |
39 |
Correct |
646 ms |
29572 KB |
Output is correct |
40 |
Correct |
639 ms |
29548 KB |
Output is correct |
41 |
Correct |
618 ms |
29552 KB |
Output is correct |
42 |
Correct |
621 ms |
29608 KB |
Output is correct |
43 |
Correct |
635 ms |
29644 KB |
Output is correct |
44 |
Correct |
664 ms |
29544 KB |
Output is correct |
45 |
Correct |
625 ms |
29720 KB |
Output is correct |
46 |
Correct |
647 ms |
29588 KB |
Output is correct |
47 |
Correct |
624 ms |
29576 KB |
Output is correct |
48 |
Correct |
5 ms |
4268 KB |
Output is correct |
49 |
Correct |
6 ms |
4232 KB |
Output is correct |
50 |
Runtime error |
10 ms |
5844 KB |
Execution killed with signal 11 |
51 |
Halted |
0 ms |
0 KB |
- |