Submission #73943

# Submission time Handle Problem Language Result Execution time Memory
73943 2018-08-29T10:09:47 Z Batmend4 Simurgh (IOI17_simurgh) C++
Compilation error
0 ms 0 KB
#include "simurgh.h"
#include<queue>
using namespace std;



vector<int> find_roads(int n, vector<int> u, vector<int> v) {
    vector<int> motherfickinggoldenroads;
    map<int, bool> usedh;
    vector< pair<int, int> > ed[n];
    for( int i = 0 ; i < u.size() ; i++ ){
        ed[u[i]].push_back(make_pair( v[i], i) );
        ed[v[i]].push_back(make_pair( u[i], i) );
    }
    
    for( int i = 0 ; i < n ; i++ ){
        vector<int> ct;
        int pos = 0;
        int used[n];
        memset(used, -1, sizeof used);
        used[i] = 1000000007;
        for( int j = 0 ; j < n ; j++ ){
            if( used[j] != -1 ) continue;
            queue< int >q;
            q.push(j);
            used[j] = pos;
            
            while( !q.empty()){
                int x = q.front();
                q.pop();
                for( int i = 0 ; i < ed[x].size() ; i++ ){
                    if( used[ed[x][i].first] != -1 ) continue;
                    ct.push_back( ed[x][i].second );
                    used[ed[x][i].first] = pos;
                    q.push( ed[x][i].first);
                }
            }
        
            pos++;
        }
        vector<int> edge[pos + 5];
        vector<pair<int, int> > impo[pos + 5];
        for( int j = 0 ; j < ed[i].size() ; j++ ){
            edge[used[ed[i][j].first]].push_back(ed[i][j].second);
        }
        for( int j = 0 ; j < pos ; j++ ){
            ct.push_back(edge[j][0]);
        }
        for( int j = 0 ; j < ed[i].size() ; j++ ){
            if( ed[i][j].first > i ) continue;
            ct[n - 2 - (pos - 1) + used[ed[i][j].first]] = ed[i][j].second;
            impo[used[ed[i][j].first]].push_back(make_pair(count_common_roads(ct), ed[i][j].second));
        }
        for( int j = 0 ; j < pos ; j++ ){
            sort( impo[j].begin(), impo[j].end() );
            int si = impo[j].size();
            int x = impo[j][si - 1].first;
            for( int ii = si - 1 ; ii >= 0 ; ii-- ){
                if( impo[j][ii].first != x ) continue;
                motherfickinggoldenroads.push_back(impo[j][ii].second);
            }
        }
    }
    return motherfickinggoldenroads;
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:9:5: error: 'map' was not declared in this scope
     map<int, bool> usedh;
     ^~~
simurgh.cpp:9:9: error: expected primary-expression before 'int'
     map<int, bool> usedh;
         ^~~
simurgh.cpp:11:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for( int i = 0 ; i < u.size() ; i++ ){
                      ~~^~~~~~~~~~
simurgh.cpp:20:9: error: 'memset' was not declared in this scope
         memset(used, -1, sizeof used);
         ^~~~~~
simurgh.cpp:31:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for( int i = 0 ; i < ed[x].size() ; i++ ){
                                  ~~^~~~~~~~~~~~~~
simurgh.cpp:43:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for( int j = 0 ; j < ed[i].size() ; j++ ){
                          ~~^~~~~~~~~~~~~~
simurgh.cpp:49:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for( int j = 0 ; j < ed[i].size() ; j++ ){
                          ~~^~~~~~~~~~~~~~
simurgh.cpp:55:13: error: 'sort' was not declared in this scope
             sort( impo[j].begin(), impo[j].end() );
             ^~~~
simurgh.cpp:55:13: note: suggested alternative: 'short'
             sort( impo[j].begin(), impo[j].end() );
             ^~~~
             short