답안 #684423

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
684423 2023-01-21T06:45:49 Z horiseun 항공 노선도 (JOI18_airline) C++11
0 / 100
496 ms 19488 KB
#include "Alicelib.h"
#include <iostream>
#include <vector>
#include <set>
#include <tuple>
#include <cassert>
#include <algorithm>
using namespace std;

#define f first
#define s second

void Alice(int N, int M, int A[], int B[]) {
    vector<int> deg(1e6, 0);
    vector<pair<int, int>> edges;
    for (int i = 0; i < M; i++) {
        edges.push_back({A[i], B[i]});
        deg[A[i]]++;
        deg[B[i]]++;
    }
    int mx = 0;
    for (int i = N - 1; i >= 0; i--) {
        mx = max(mx, deg[i] + i + 1);
    }
    int nd = N;
    for (int i = 0; i < N; i++) {
        while (deg[i] < mx) {
            edges.push_back({i, nd++});
            deg[i]++;
            deg[nd]++;
        }
        mx--;
    }
    InitG(nd, edges.size());
    for (int i = 0; i < edges.size(); i++) {
        MakeG(i, edges[i].f, edges[i].s);
    }
    return;
}
#include "Boblib.h"
#include <iostream>
#include <vector>
#include <set>
#include <tuple>
#include <cassert>
#include <algorithm>
using namespace std;

#define f first
#define s second

void Bob(int V, int U, int C[], int D[]) {
    vector<int> deg(V, 0);
    for (int i = 0; i < U; i++) {
        deg[C[i]]++;
        deg[D[i]]++;
    }
    vector<pair<int, int>> nds;
    for (int i = 0; i < V; i++) {
        nds.push_back({deg[i], i});
    }
    sort(nds.begin(), nds.end(), greater<pair<int, int>>());
    vector<int> mp(V, 0);
    for (int i = 0; i < V; i++) {
        mp[nds[i].s] = i;
    }
    vector<pair<int, int>> edges;
    set<int> s;
    for (int i = 0; i < U; i++) {
        if (deg[C[i]] == 1 && deg[D[i]] == 1) continue;
        else if (deg[C[i]] == 1) {
            s.insert(mp[D[i]]);
            continue;
        } else if (deg[D[i]] == 1) {
            s.insert(mp[C[i]]);
            continue;
        }
        edges.push_back({mp[C[i]], mp[D[i]]});
        s.insert(mp[C[i]]);
        s.insert(mp[D[i]]);
    }
    InitMap(s.size(), edges.size());
    for (int i = 0; i < edges.size(); i++) {
        MakeMap(edges[i].f, edges[i].s);
    }
    return;
}

Compilation message

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

Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i = 0; i < edges.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8580 KB Output is correct
2 Correct 4 ms 8600 KB Output is correct
3 Correct 4 ms 8508 KB Output is correct
4 Incorrect 4 ms 8596 KB Wrong Answer [10]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8580 KB Output is correct
2 Correct 4 ms 8600 KB Output is correct
3 Correct 4 ms 8508 KB Output is correct
4 Incorrect 4 ms 8596 KB Wrong Answer [10]
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 496 ms 19488 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -