Submission #293244

#TimeUsernameProblemLanguageResultExecution timeMemory
293244CaroLindaMonochrome Points (JOI20_monochrome)C++14
25 / 100
2083 ms504 KiB
#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define pii pair<int,int>
#define mk make_pair
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define debug printf
#define lp(i,a,b) for(int i = a ; i < b ; i++ )
#define sz(x) (int)(x.size())

const int MAXN = 4010 ;

using namespace std ;

int N , ans ;
int myPair[MAXN] ;
vector<int> aux ;
vector<pii> lines ;
char str[MAXN] ;

int checkIntersection( pii p1 , pii p2 )
{

    if( p1.ff > p1.ss ) swap(p1.ff, p1.ss ) ;

    int type1 = ( p2.ff > p1.ff && p2.ff < p1.ss )&( p2.ss > p1.ff && p2.ss < p1.ss ) ;
    int type2 = ( p2.ff > p1.ss || p2.ff < p1.ff )&( p2.ss > p1.ss || p2.ss < p1.ff ) ;

    return type1 == 0 && type2 == 0 ;

}

int main()
{
    scanf("%d", &N ) ;
    scanf("%s", str ) ;

    for(int i = 1 ; i < 2*N ; i++ )
    {
        if( str[i] == str[0] ) continue ;

        lines.clear() ;

        for(int j = i+1 ; j != i ; j++ )
        {
            if( j == 2*N ) j = 0 ;
            if(str[j] != str[i]) continue ;
            aux.pb( j ) ;
        }

        reverse(all(aux)) ;

        lines.pb( mk(0,i) ) ;

        for(int j = 1 ; j != 2*N ; j++ )
        {
            if( str[j] != str[0] ) continue ;

            lines.pb( mk( j , aux.back() ) ) ;
            aux.pop_back() ;

        }

        int temp = 0 ;

        for(int a = 0 ; a < sz(lines) ; a++ )
            for(int b = a+1 ; b < sz(lines) ; b++ )
                temp += checkIntersection( lines[a] , lines[b] ) ;

        ans = max(ans, temp) ;

    }

    printf("%d\n" , ans ) ;

}

Compilation message (stderr)

monochrome.cpp: In function 'int main()':
monochrome.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   38 |     scanf("%d", &N ) ;
      |     ~~~~~^~~~~~~~~~~
monochrome.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   39 |     scanf("%s", str ) ;
      |     ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...