#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;
edges.push_back({mp[C[i]], mp[D[i]]});
}
for (int i = 0; i < V; i++) {
if (deg[i] != 1) {
s.insert(mp[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:40: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]
40 | for (int i = 0; i < edges.size(); i++) {
| ~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8580 KB |
Output is correct |
2 |
Correct |
4 ms |
8580 KB |
Output is correct |
3 |
Correct |
3 ms |
8600 KB |
Output is correct |
4 |
Incorrect |
4 ms |
8600 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 |
8580 KB |
Output is correct |
3 |
Correct |
3 ms |
8600 KB |
Output is correct |
4 |
Incorrect |
4 ms |
8600 KB |
Wrong Answer [10] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
376 ms |
19420 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |