Submission #656074

#TimeUsernameProblemLanguageResultExecution timeMemory
656074andrei_marciucTriangles (CEOI18_tri)C++14
Compilation error
0 ms0 KiB
#include <algorithm>
#include <vector>
#include "trilib.c"
using namespace std;

vector<int> componenta[ 2 ];
vector<int> divide[ 2 ];

inline bool cmp( const int& a, const int& b ) {
    return is_clockwise( 1, a, b );
}

int main() 
{
    n = get_n();
    for( int i = 0; i < 2; i++ )
        divide[ i ].push_back( 2 );
    for( int i = 3; i <= n; i++ )
        divide[ is_clockwise( 1, 2, i ) ].push_back( i );
    
    for( int comp = 0; comp < 2; comp++ ) {
        sort( divide[ comp ].begin(), divide[ comp ].end(), cmp );
        for( vector<int>::iterator it = divide[ comp ].begin(); it != divide[ comp ].end(); it++ ) {
            int right = componenta[ comp ].size();
            while( right > 1 && !is_clockwise( componenta[ comp ][ right - 2 ], componenta[ comp ].back(), *it ) ) {
                componenta[ comp ].pop_back();
                right--;
            }
            componenta[ comp ].push_back( *it );
        }
        if( comp )
            reverse( componenta[ comp ].begin(), componenta[ comp ].end() );
        componenta[ comp ].insert( componenta[ comp ].begin(), 1 );
        
    }

    /*for( int comp = 0; comp < 2; comp++ ) {
        for( int i : componenta[ comp ] )
            cout << i << ' ';
        cout << '\n';
    }*/

    for( int comp = 0; comp < 2; comp++ ) {
        componenta[ 0 ].pop_back();

        bool good = false;
        while( !good ) {
            good = true;
            if( componenta[ 0 ].size() > 1 && !( comp ^ is_clockwise( componenta[ 0 ][ componenta[ 0 ].size() - 2 ], componenta[ 0 ].back(), componenta[ 1 ].back() ) ) ) {
                componenta[ 0 ].pop_back();
                good = false;
            }

            if( componenta[ 1 ].size() > 1 && !( comp ^ is_clockwise( componenta[ 0 ].back(), componenta[ 1 ].back(), componenta[ 1 ][ componenta[ 1 ].size() - 2 ] ) ) ) {
                componenta[ 1 ].pop_back();
                good = false;
            }    
        }
        swap( componenta[ 0 ], componenta[ 1 ] );

    }

    give_answer( componenta[ 0 ].size() + componenta[ 1 ].size() );
    return 0;
}
/*
6
1 1
4 3
2 2
1 4
5 1
3 2
*/

Compilation message (stderr)

/usr/bin/ld: /tmp/ccgdSXKT.o: in function `get_n':
tri.cpp:(.text+0x220): multiple definition of `get_n'; /tmp/ccRdzUfT.o:trilib.c:(.text+0x120): first defined here
/usr/bin/ld: /tmp/ccgdSXKT.o: in function `is_clockwise':
tri.cpp:(.text+0x290): multiple definition of `is_clockwise'; /tmp/ccRdzUfT.o:trilib.c:(.text+0x190): first defined here
/usr/bin/ld: /tmp/ccgdSXKT.o: in function `give_answer':
tri.cpp:(.text+0x3f0): multiple definition of `give_answer'; /tmp/ccRdzUfT.o:trilib.c:(.text+0x2f0): first defined here
collect2: error: ld returned 1 exit status