답안 #579127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579127 2022-06-18T12:01:08 Z ogibogi2004 Simurgh (IOI17_simurgh) C++14
13 / 100
24 ms 6684 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(vis[xd.first])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++)
    {
        //cout<<i<<endl;
        memset(vis,0,sizeof(vis));
        vis[i]=1;
        qe.clear();
        if(i==0)
        {
            dfs(1,-1);
        }
        else
        {
            dfs(0,-1);
        }
        //cout<<"?\n";
        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:54:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |         if(qe.size()<n-2)
      |            ~~~~~~~~~^~~~
simurgh.cpp:56: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]
   56 |             for(int j=1;j<g[i].size();j++)
      |                         ~^~~~~~~~~~~~
simurgh.cpp:65: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]
   65 |             for(int j=0;j<g[i].size();j++)
      |                         ~^~~~~~~~~~~~
simurgh.cpp:72: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]
   72 |             for(int j=1;j<edg.size();j++)
      |                         ~^~~~~~~~~~~
simurgh.cpp:81:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |     for(int i=0;i<u.size();i++)
      |                 ~^~~~~~~~~
simurgh.cpp:94:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   94 |     if(comp[0].size()==n-1)return comp[0];
      |        ~~~~~~~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1856 KB correct
2 Correct 1 ms 1852 KB correct
3 Correct 2 ms 1876 KB correct
4 Correct 2 ms 1876 KB correct
5 Correct 2 ms 1876 KB correct
6 Correct 2 ms 1876 KB correct
7 Correct 2 ms 1876 KB correct
8 Correct 1 ms 1876 KB correct
9 Correct 1 ms 1876 KB correct
10 Correct 1 ms 1876 KB correct
11 Correct 1 ms 1852 KB correct
12 Correct 2 ms 1852 KB correct
13 Correct 2 ms 1876 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1856 KB correct
2 Correct 1 ms 1852 KB correct
3 Correct 2 ms 1876 KB correct
4 Correct 2 ms 1876 KB correct
5 Correct 2 ms 1876 KB correct
6 Correct 2 ms 1876 KB correct
7 Correct 2 ms 1876 KB correct
8 Correct 1 ms 1876 KB correct
9 Correct 1 ms 1876 KB correct
10 Correct 1 ms 1876 KB correct
11 Correct 1 ms 1852 KB correct
12 Correct 2 ms 1852 KB correct
13 Correct 2 ms 1876 KB correct
14 Correct 4 ms 2004 KB correct
15 Correct 5 ms 2004 KB correct
16 Correct 6 ms 2004 KB correct
17 Correct 4 ms 1984 KB correct
18 Correct 3 ms 1852 KB correct
19 Correct 5 ms 2004 KB correct
20 Correct 5 ms 1928 KB correct
21 Correct 4 ms 1980 KB correct
22 Runtime error 7 ms 3924 KB Execution killed with signal 6
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1856 KB correct
2 Correct 1 ms 1852 KB correct
3 Correct 2 ms 1876 KB correct
4 Correct 2 ms 1876 KB correct
5 Correct 2 ms 1876 KB correct
6 Correct 2 ms 1876 KB correct
7 Correct 2 ms 1876 KB correct
8 Correct 1 ms 1876 KB correct
9 Correct 1 ms 1876 KB correct
10 Correct 1 ms 1876 KB correct
11 Correct 1 ms 1852 KB correct
12 Correct 2 ms 1852 KB correct
13 Correct 2 ms 1876 KB correct
14 Correct 4 ms 2004 KB correct
15 Correct 5 ms 2004 KB correct
16 Correct 6 ms 2004 KB correct
17 Correct 4 ms 1984 KB correct
18 Correct 3 ms 1852 KB correct
19 Correct 5 ms 2004 KB correct
20 Correct 5 ms 1928 KB correct
21 Correct 4 ms 1980 KB correct
22 Runtime error 7 ms 3924 KB Execution killed with signal 6
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1876 KB correct
2 Correct 2 ms 1876 KB correct
3 Runtime error 24 ms 6684 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1856 KB correct
2 Correct 1 ms 1852 KB correct
3 Correct 2 ms 1876 KB correct
4 Correct 2 ms 1876 KB correct
5 Correct 2 ms 1876 KB correct
6 Correct 2 ms 1876 KB correct
7 Correct 2 ms 1876 KB correct
8 Correct 1 ms 1876 KB correct
9 Correct 1 ms 1876 KB correct
10 Correct 1 ms 1876 KB correct
11 Correct 1 ms 1852 KB correct
12 Correct 2 ms 1852 KB correct
13 Correct 2 ms 1876 KB correct
14 Correct 4 ms 2004 KB correct
15 Correct 5 ms 2004 KB correct
16 Correct 6 ms 2004 KB correct
17 Correct 4 ms 1984 KB correct
18 Correct 3 ms 1852 KB correct
19 Correct 5 ms 2004 KB correct
20 Correct 5 ms 1928 KB correct
21 Correct 4 ms 1980 KB correct
22 Runtime error 7 ms 3924 KB Execution killed with signal 6
23 Halted 0 ms 0 KB -