Submission #36660095
Source Code Expand
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
int main() {
int N,M;
cin >> N >> M;
vector<vector<int>> graph(N+1);
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
graph[a].push_back(b);
graph[b].push_back(a);
}
for (int i = 0; i < N + 1; i++) {
sort(graph[i].begin(), graph[i].end());
}
for (int i = 1; i <= N; i++) {
cout << graph[i].size() ;
for (int j = 0; j < graph[i].size(); j++) {
cout<<" " << graph[i][j] ;
}
cout << endl;
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Adjacency List |
| User | amaoto |
| Language | C++ (GCC 9.2.1) |
| Score | 200 |
| Code Size | 739 Byte |
| Status | AC |
| Exec Time | 226 ms |
| Memory | 8940 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:25:27: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
25 | for (int j = 0; j < graph[i].size(); j++) {
| ~~^~~~~~~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 7 ms | 3628 KiB |
| example_01.txt | AC | 3 ms | 3496 KiB |
| test_00.txt | AC | 226 ms | 8276 KiB |
| test_01.txt | AC | 225 ms | 8060 KiB |
| test_02.txt | AC | 60 ms | 4348 KiB |
| test_03.txt | AC | 78 ms | 4712 KiB |
| test_04.txt | AC | 101 ms | 5136 KiB |
| test_05.txt | AC | 203 ms | 8940 KiB |
| test_06.txt | AC | 217 ms | 8724 KiB |
| test_07.txt | AC | 5 ms | 3600 KiB |