#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> PII;
constexpr int NMAX = 1e5 + 5;
int N, M;
vector <int> G[NMAX];
map <PII, int> mp;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N >> M;
for (int i = 1; i <= M; ++ i ) {
int x, y;
cin >> x >> y;
if (x > y) swap(x, y);
G[x].push_back(y);
mp[{x, y}] = true;
}
for (int i = 1; i <= N; ++ i ) {
sort(G[i].begin(), G[i].end());
for (int j = 0; j < G[i].size(); ++ j ) {
for (int k = j+1; k < G[i].size(); ++ k ) {
int x = G[i][j], y = G[i][k];
if (!mp[{x, y}]) {
G[x].push_back(y);
mp[{x, y}] = true;
}
}
}
}
cout << mp.size() << '\n';
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:33:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int j = 0; j < G[i].size(); ++ j ) {
| ~~^~~~~~~~~~~~~
Main.cpp:34:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for (int k = j+1; k < G[i].size(); ++ k ) {
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
13 ms |
2924 KB |
Output is correct |
4 |
Correct |
10 ms |
3016 KB |
Output is correct |
5 |
Correct |
11 ms |
2940 KB |
Output is correct |
6 |
Correct |
12 ms |
3036 KB |
Output is correct |
7 |
Correct |
11 ms |
3028 KB |
Output is correct |
8 |
Correct |
12 ms |
3040 KB |
Output is correct |
9 |
Correct |
8 ms |
2928 KB |
Output is correct |
10 |
Correct |
12 ms |
3016 KB |
Output is correct |
11 |
Correct |
11 ms |
2900 KB |
Output is correct |
12 |
Correct |
12 ms |
3036 KB |
Output is correct |
13 |
Correct |
11 ms |
3032 KB |
Output is correct |
14 |
Correct |
12 ms |
3040 KB |
Output is correct |
15 |
Correct |
9 ms |
2900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
13 ms |
2924 KB |
Output is correct |
4 |
Correct |
10 ms |
3016 KB |
Output is correct |
5 |
Correct |
11 ms |
2940 KB |
Output is correct |
6 |
Correct |
12 ms |
3036 KB |
Output is correct |
7 |
Correct |
11 ms |
3028 KB |
Output is correct |
8 |
Correct |
12 ms |
3040 KB |
Output is correct |
9 |
Correct |
8 ms |
2928 KB |
Output is correct |
10 |
Correct |
12 ms |
3016 KB |
Output is correct |
11 |
Correct |
11 ms |
2900 KB |
Output is correct |
12 |
Correct |
12 ms |
3036 KB |
Output is correct |
13 |
Correct |
11 ms |
3032 KB |
Output is correct |
14 |
Correct |
12 ms |
3040 KB |
Output is correct |
15 |
Correct |
9 ms |
2900 KB |
Output is correct |
16 |
Execution timed out |
4024 ms |
220912 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4080 ms |
166112 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
13 ms |
2924 KB |
Output is correct |
4 |
Correct |
10 ms |
3016 KB |
Output is correct |
5 |
Correct |
11 ms |
2940 KB |
Output is correct |
6 |
Correct |
12 ms |
3036 KB |
Output is correct |
7 |
Correct |
11 ms |
3028 KB |
Output is correct |
8 |
Correct |
12 ms |
3040 KB |
Output is correct |
9 |
Correct |
8 ms |
2928 KB |
Output is correct |
10 |
Correct |
12 ms |
3016 KB |
Output is correct |
11 |
Correct |
11 ms |
2900 KB |
Output is correct |
12 |
Correct |
12 ms |
3036 KB |
Output is correct |
13 |
Correct |
11 ms |
3032 KB |
Output is correct |
14 |
Correct |
12 ms |
3040 KB |
Output is correct |
15 |
Correct |
9 ms |
2900 KB |
Output is correct |
16 |
Execution timed out |
4024 ms |
220912 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |