CSES - HIIT Open 2018 - Results
Submission details
Task:Euclidean Geometry
Sender:Karhukopla
Submission time:2018-05-26 13:28:10 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.07 sdetails
#20.07 sdetails
#30.07 sdetails
#40.08 sdetails
#50.07 sdetails
#60.09 sdetails
#70.07 sdetails
#80.06 sdetails

Compiler report

input/code.cpp: In function 'int solve()':
input/code.cpp:38:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<q.size(); ++i){
               ~^~~~~~~~~
input/code.cpp:40:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=i+1; j<q.size(); ++j){
                            ~^~~~~~~~~

Code

#include <bits/stdc++.h>

#define ll long long
#define lll __int128
#define pii pair<int, int>
#define M 1000000007
#define N 101
#define PB push_back
#define F first
#define S second
using namespace std;

char t[N][N];

int solve(){
	int x1=N, y1=N, x2=0, y2=0;
	for(int i=0; i<100; ++i) {
		for(int j=0; j<100; ++j) {
			cin >> t[i][j];
			if(t[i][j] == '1') {
				x1=min(x1, i);
				x2=max(x2, i);
				y1=min(y1, j);
				y2=max(y2, j);
			}
		}
	}
	vector<pair<int,int>> q;
	for(int i=x1; i<=x2; ++i){
		if(t[i][y1]=='1' && (t[i-1][y1]=='0'||t[i+1][y1] == '0')) q.PB({i, y1});
		if(t[i][y2]=='1' && (t[i-1][y2]=='0'||t[i+1][y2] == '0')) q.PB({i, y2});
	}for(int i=y1; i<=y2; ++i){
		if(t[x1][i]=='1' && (t[x1][i-1]=='0'||t[x1][i+1] == '0')) q.PB({x1, i});
		if(t[x2][i]=='1' && (t[x2][i-1]=='0'||t[x2][i+1] == '0')) q.PB({x2, i});
	}
	vector<pair<int,int>> sivut;
        vector<int> z(10);
	for(int i=0; i<q.size(); ++i){
            if(z[i]) continue;
            for(int j=i+1; j<q.size(); ++j){
                int a = q[i].F - q[j].F, b = q[i].S - q[j].S;
                if(a*a+b*b < 100) {
                    z[j] = 1;
                    continue;
                }
                sivut.PB({i, j});
            }
	}
	if(sivut.size() > 3) return 4;
        for(pair<int,int> p : sivut){
            int a = p.F, b = p.S;
            int x = (q[a].F + q[b].F)/2, y = (q[a].S + q[b].S)/2;
            vector<int> w(2);
            for(int i=x-3; i<=x+3; ++i){
                for(int j=y-3; j<=y+3; ++j){
                    if(t[i][j] == '1') w[1] = 1;
                    else w[2] = 1;
                }
            }
            if(w[1] + w[2] == 1){
                return 4;
            }
        }
        if(sivut.size() == 3) return 3;
        pair<int,int> pist = {x1, y2};
        int dist = 0;
        for(int i=x1; i<=x2; ++i){
            for(int j=0; j<100; ++j){
                if(t[i][j] == '0') continue;
                int d = abs((x1-i)*(y2-j) - (x2-i)*(y1-j));
                if(d > dist){
                    dist = d;
                    pist = {i, j};
                }
            }
        }
        int a = sivut[0].F, b = sivut[0].S;
        int x = (q[a].F + pist.F)/2, y = (q[a].S + pist.S)/2;
        vector<int> w(2);
        for(int i=x-3; i<=x+3; ++i){
            for(int j=y-3; j<=y+3; ++j){
                if(t[i][j] == '1') w[1] = 1;
                else w[2] = 1;
            }
        }
        if(w[1] + w[2] == 1){
            return 4;
        }
        x = (q[b].F + pist.F)/2, y = (q[b].S + pist.S)/2;
        w[0] = w[1] = 0;
        for(int i=x-3; i<=x+3; ++i){
            for(int j=y-3; j<=y+3; ++j){
                if(t[i][j] == '1') w[1] = 1;
                else w[2] = 1;
            }
        }
        if(w[1] + w[2] == 1){
            return 4;
        }
        return 3;
}

int main () {
	ll t; cin >> t;
	while(t--) cout << solve() << "\n";
}

/**
AAU
YBA
BTY
*/

Test details

Test 1

Verdict:

input
100
000000000000000000000000000000...

correct output
3
3
3
3
4
...

user output
4
4
4
4
4
...
Truncated

Test 2

Verdict:

input
100
000000000000000000000000000000...

correct output
3
4
4
4
3
...

user output
4
4
4
4
4
...
Truncated

Test 3

Verdict:

input
100
000000000000000000000000000000...

correct output
3
3
3
3
4
...

user output
4
4
4
4
4
...
Truncated

Test 4

Verdict:

input
100
000000000000000000000000000000...

correct output
3
3
3
4
3
...

user output
4
4
4
4
4
...
Truncated

Test 5

Verdict:

input
100
000000000000000000000000000000...

correct output
3
4
3
3
4
...

user output
4
4
4
4
4
...
Truncated

Test 6

Verdict:

input
100
000000000000000000000000000000...

correct output
4
3
4
4
4
...

user output
4
4
4
4
4
...
Truncated

Test 7

Verdict:

input
100
000000000000000000000000000000...

correct output
4
4
3
3
3
...

user output
4
4
4
4
4
...
Truncated

Test 8

Verdict:

input
100
000000000000000000000000000000...

correct output
3
3
3
3
3
...

user output
4
4
4
4
4
...
Truncated