Submission #231211

# Submission time Handle Problem Language Result Execution time Memory
231211 2020-05-13T04:34:44 Z mohamedsobhi777 Mountains (IOI17_mountains) C++14
0 / 100
249 ms 384 KB
/*
        Pure bruteforce
*/
#include "mountains.h"
#include <bits/stdc++.h>

using namespace std ; 

int maximum_deevs(std::vector<int> y) {
        int ret = 0 ; 
        int n = y.size() ; 

        for(int i = 1 ; i < (1<<n) ; i++){
                vector<pair<int , int> > prs ; 
                for(int j = 0 ;j < n ;j++){
                        if(i &(1<<j)){
                                prs.push_back({j , y[j]}) ; 
                        }
                }
                if(prs.size() < ret) continue ; 
                bool okk = 1 ; 
                for(int j = 0 ; j < prs.size() ; j++){
                        for(int k = j +1 ; k < prs.size() ; k++){
                                bool ok = 0 ; 
                                for(int l = prs[j].first +1 ; l < prs[k].first ; l++){
                                        complex<double> v1 (l - prs[j].first , y[l] - prs[j].second);
                                        complex<double> v2(prs[k].first - l , prs[k].second - y[l]) ; 
                                        int dot = (conj(v1) * v2) .imag() ; 
                                        if(dot < 0) ok = 1; 
                                }
                                if(!ok){
                                        okk = 0 ;
                                        j = prs.size() ;  
                                        break ; 
                                }
                        }
                }
                if(okk){
                        ret = max(ret , (int) prs.size()) ; 
                }
        }

	return ret;
}

Compilation message

mountains.cpp: In function 'int maximum_deevs(std::vector<int>)':
mountains.cpp:20:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(prs.size() < ret) continue ; 
                    ~~~~~~~~~~~^~~~~
mountains.cpp:22:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j = 0 ; j < prs.size() ; j++){
                                 ~~^~~~~~~~~~~~
mountains.cpp:23:46: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                         for(int k = j +1 ; k < prs.size() ; k++){
                                            ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 249 ms 256 KB Output is correct
7 Incorrect 208 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 249 ms 256 KB Output is correct
7 Incorrect 208 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 249 ms 256 KB Output is correct
7 Incorrect 208 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 249 ms 256 KB Output is correct
7 Incorrect 208 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -