This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 solve(int N, int L)
{
vector<vector<int>> AR(N);
vector<int> occ(N);
for (int i = N - 1; i >= 0; i--)
{
if (occ[i])
continue;
occ[i] = 1;
vector<int> occ2(N);
for (int k = 1; k < N; k++)
{
int x = query(i + 1, k) - 1;
if (occ2[x])
break;
AR[i].push_back(x);
if (!occ[x])
{
for (int j = 1; j < N; j++)
{
int y = query(x + 1, j) - 1;
AR[x].push_back(y);
if (y == i)
break;
}
occ[x] = 1;
}
for (int j = 0; j < AR[AR[i][k - 1]].size(); j++)
{
occ2[AR[AR[i][k - 1]][j]] = 1;
}
}
}
for (int i = 0; i < N; i++)
{
for (int j = 0; j < AR[i].size(); j++)
{
if (AR[i][j] < i)
answer(AR[i][j] + 1, i + 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);
}*/
Compilation message (stderr)
island.cpp: In function 'void solve(int, int)':
island.cpp:41:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for (int j = 0; j < AR[AR[i][k - 1]].size(); j++)
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~
island.cpp:49:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for (int j = 0; j < AR[i].size(); j++)
| ~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |