Submission #579124

# Submission time Handle Problem Language Result Execution time Memory
579124 2022-06-18T11:58:51 Z ogibogi2004 Simurgh (IOI17_simurgh) C++14
0 / 100
797 ms 1048576 KB
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=256;
vector<pair<int,int> >g[MAXN];
vector<int>g1[MAXN*MAXN];
vector<int>qe;
bool vis[MAXN*MAXN];
void dfs(int u,int par)
{
    vis[u]=1;
    for(auto xd:g[u])
    {
        if(xd.first==par)continue;
        qe.push_back(xd.second);
        dfs(xd.first,u);
    }
}
vector<vector<int>>comp;
void dfs1(int u)
{
    vis[u]=1;
    comp[comp.size()-1].push_back(u);
    for(auto xd:g1[u])
    {
        if(vis[xd]==0)
        {
            dfs1(xd);
        }
    }
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
    for(int i=0;i<u.size();i++)
    {
        g[u[i]].push_back({v[i],i});
        g[v[i]].push_back({u[i],i});
    }
    vector<int>royal;
    for(int i=0;i<n;i++)
    {
        memset(vis,0,sizeof(vis));
        vis[i]=1;
        qe.clear();
        if(i==0)
        {
            dfs(1,-1);
        }
        else
        {
            dfs(0,-1);
        }
        if(qe.size()<n-2)
        {
            for(int j=1;j<g[i].size();j++)
            {
                g1[g[i][j-1].second].push_back(g[i][j].second);
                g1[g[i][j].second].push_back(g[i][j-1].second);
            }
        }
        else
        {
            vector<pair<int,int> >edg;
            for(int j=0;j<g[i].size();j++)
            {
                qe.push_back(g[i][j].second);
                edg.push_back({count_common_roads(qe),g[i][j].second});
                qe.pop_back();
            }
            sort(edg.begin(),edg.end());
            for(int j=1;j<edg.size();j++)
            {
                if(edg[j].first!=edg[j-1].first)continue;
                g1[edg[j].second].push_back(edg[j-1].second);
                g1[edg[j-1].second].push_back(edg[j].second);
            }
        }
    }
    memset(vis,0,sizeof(vis));
    for(int i=0;i<u.size();i++)
    {
        if(vis[i]==0)
        {
            comp.push_back({});
            dfs1(i);
        }
    }
    if(comp[0].size()==comp[1].size())
    {
        if(count_common_roads(comp[0])==n-1)return comp[0];
        else return comp[1];
    }
    if(comp[0].size()==n-1)return comp[0];
    return comp[1];
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i<u.size();i++)
      |                 ~^~~~~~~~~
simurgh.cpp:52:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |         if(qe.size()<n-2)
      |            ~~~~~~~~~^~~~
simurgh.cpp:54:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |             for(int j=1;j<g[i].size();j++)
      |                         ~^~~~~~~~~~~~
simurgh.cpp:63:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |             for(int j=0;j<g[i].size();j++)
      |                         ~^~~~~~~~~~~~
simurgh.cpp:70:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             for(int j=1;j<edg.size();j++)
      |                         ~^~~~~~~~~~~
simurgh.cpp:79:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     for(int i=0;i<u.size();i++)
      |                 ~^~~~~~~~~
simurgh.cpp:92:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   92 |     if(comp[0].size()==n-1)return comp[0];
      |        ~~~~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 797 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 797 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 797 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1876 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 797 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -