Submission #293565

#TimeUsernameProblemLanguageResultExecution timeMemory
293565BadrangiikhFriend (IOI14_friend)C++14
11 / 100
1034 ms5112 KiB
#include<bits/stdc++.h> using namespace std; int x , y , a [ 45 ] , maxx , flag ; vector < int > vec [ 1005 ] ; int findSample ( int N , int confidence[] , int host[] , int protocol[] ) { if ( N <= 10 ) { maxx = 0 ; for ( int i = 1 ; i < N ; i ++ ) { if ( protocol [ i ] == 0 ) { vec [ i ] . push_back ( host [ i ] ) ; vec [ host [ i ] ] . push_back ( i ) ; } if ( protocol [ i ] == 1 ) { for ( int j = 0 ; j < vec [ host [ i ] ] . size ( ) ; j ++ ) { vec [ i ] . push_back ( vec [ host [ i ] ] [ j ] ) ; vec [vec [ host[ i ] ][ j ] ] . push_back ( i ) ; } } if ( protocol [ i ] == 2 ) { for ( int j = 0 ; j < vec [ host [ i ] ] . size ( ) ; j ++ ) { vec [ i ] . push_back ( vec [ host [ i ] ] [ j ] ) ; vec [ vec [ host[ i ] ][ j ] ] . push_back ( i ) ; } vec [ i ] . push_back ( host [ i ] ) ; vec [ host [ i ] ] . push_back ( i ) ; } } for ( int i = 1 ; i <= 2048 ; i ++ ) { x = i ; y = 0 ; flag = true ; for ( int j = 0 ; j < N ; j ++ ) { a [ j ] = x % 2 ; x /= 2 ; if ( a [ j ] == 1 ) { y += confidence [ j ] ; } } for ( int j = 0 ; j < N ; j ++ ) { for ( int l = 0 ; l < N ; l ++ ) { if ( a [ j ] == 1 && a [ l ] == 1 ) { for ( int k = 0 ; k < vec [ j ] . size ( ) ; k ++ ) { if ( vec [ j ] [ k ] == l ){ flag = false ; } } } } } if ( flag == true ) { maxx = max ( maxx , y ) ; } } return maxx ; } }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:16:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |                 for ( int j = 0 ; j < vec [ host [ i ] ] . size ( ) ; j ++ ) {
      |                                   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
friend.cpp:22:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |                 for ( int j = 0 ; j < vec [ host [ i ] ] . size ( ) ; j ++ ) {
      |                                   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
friend.cpp:44:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |                         for ( int k = 0 ; k < vec [ j ] . size ( ) ; k ++ ) {
      |                                           ~~^~~~~~~~~~~~~~~~~~~~~~
friend.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...