답안 #991853

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
991853 2024-06-03T08:54:03 Z simona1230 항공 노선도 (JOI18_airline) C++17
0 / 100
225 ms 20168 KB
#include <bits/stdc++.h>
#include "Alicelib.h"

using namespace std;

void Alice(int n,int m,int a[],int b[])
{
    vector<pair<int,int> > v;
    int l[1024];
    int num=0;
    for(int i=0;i<n;i++)
    {
        int cnt=i+3;
        l[i]=num;

        for(int j=1;j<cnt;j++)
        {
            v.push_back({num,num+1});
            num++;
        }

        v.push_back({num,num-cnt+1});

        num++;
        v.push_back({l[i],num});
        l[i]=num;
    }



    for(int i=0;i<m;i++)
    {
        v.push_back({l[a[i]],l[b[i]]});
    }


    InitG(num,v.size());
    for(int i=0;i<v.size();i++)
    {
        MakeG(i,v[i].first,v[i].second);
    }
}
#include <bits/stdc++.h>
#include "Boblib.h"

using namespace std;

int x[100001],y[100001];
vector<int> e[100001];
int used[100001];
int l[100001];
int maxx=0;

void dfs(int i,int c,int bg,int p)
{
    used[i]=1;
    for(int j=0;j<e[i].size();j++)
    {
        int nb=e[i][j];
        if(e[nb].size()==2&&nb!=p)dfs(nb,c+1,bg,i);
        else
        {
            maxx=max(maxx,c-2);
            for(int k=0;k<e[bg].size();k++)
            {
                if(!used[e[bg][i]])
                    l[e[nb][i]]=c-2;
            }
        }
    }
}

void Bob(int v,int u,int c[],int d[])
{
    for(int i=0;i<u;i++)
    {
        e[c[i]].push_back(d[i]);
        e[d[i]].push_back(c[i]);
    }

    for(int i=0;i<v;i++)
    {
        if(e[i].size()==3)dfs(i,1,i,-1);
    }

    vector<pair<int,int> > ans;
    for(int i=0;i<u;i++)
    {
        if(l[c[i]]&&l[d[i]])
            ans.push_back({l[c[i]]-1,l[d[i]]-1});
    }

    InitMap(maxx,ans.size());
    for(int i=0;i<ans.size();i++)
        MakeMap(ans[i].first,ans[i].second);
}

Compilation message

Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~

Bob.cpp: In function 'void dfs(int, int, int, int)':
Bob.cpp:15:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int j=0;j<e[i].size();j++)
      |                 ~^~~~~~~~~~~~
Bob.cpp:22:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             for(int k=0;k<e[bg].size();k++)
      |                         ~^~~~~~~~~~~~~
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int i=0;i<ans.size();i++)
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 10840 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 10840 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 225 ms 20168 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -