제출 #982861

#제출 시각아이디문제언어결과실행 시간메모리
982861raphaelpIsland Hopping (JOI24_island)C++17
43 / 100
10 ms1228 KiB
#include <bits/stdc++.h>
#include "island.h"
using namespace std;
/*vector<vector<int>> dist;
int query(int x, int k)
{
    return dist[x - 1][k] + 1;
}
void answer(int a, int b)
{
    cout << a << ' ' << b << endl;
}*/
void dfs(int x, vector<vector<int>> &AR, vector<int> &occ)
{
    occ[x] = 1;
    bool b = 0;
    int last = 0;
    for (int k = 1; k < AR.size(); k++)
    {
        int v = query(x + 1, k);
        if (last > v)
            break;
        last = v;
        v--;
        if (occ[v] == 2)
        {
            if (AR[v][x] == 1)
            {
                AR[v][x] = 2;
                AR[x][v] = 2;
                continue;
            }
            break;
        }
        if (occ[v] == 1)
        {
            if (b)
                break;
            b = 1;
            AR[x][v] = 1;
            if (AR[v][x] == 1)
            {
                AR[v][x] = 2;
                AR[x][v] = 2;
                continue;
            }
        }
        if (occ[v] == 0)
        {
            AR[x][v] = 1;
            dfs(v, AR, occ);
        }
    }
    occ[x] = 2;
}
void solve(int N, int L)
{
    vector<vector<int>> AR(N, vector<int>(N));
    vector<int> occ(N);
    dfs(0, AR, occ);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < i; j++)
        {
            if (AR[i][j] == 2)
                answer(i + 1, j + 1);
        }
    }
}
/*int main()
{
    int N, L;
    cin >> N >> L;
    vector<vector<int>> AR(N);
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        AR[a].push_back(b);
        AR[b].push_back(a);
    }
    dist.assign(N, vector<int>(N, 0));
    for (int i = 0; i < N; i++)
    {
        vector<int> occ(N);
        priority_queue<pair<int, int>> PQ;
        int buff = 0;
        PQ.push({0, -i});
        while (!PQ.empty())
        {
            int x = -PQ.top().second, t = -PQ.top().first;
            PQ.pop();
            if (occ[x])
                continue;
            occ[x] = 1;
            dist[i][buff++] = x;
            for (int j = 0; j < AR[x].size(); j++)
            {
                PQ.push({-(t + 1), -AR[x][j]});
            }
        }
    }
    solve(N, L);
}*/

컴파일 시 표준 에러 (stderr) 메시지

island.cpp: In function 'void dfs(int, std::vector<std::vector<int> >&, std::vector<int>&)':
island.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int k = 1; k < AR.size(); k++)
      |                     ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...