Submission #62771483
Source Code Expand
Copy
#include <bits/stdc++.h>using namespace std;using i64 = long long;int main() {cin.tie(nullptr) -> sync_with_stdio(false);int n, m;cin >> n >> m;int ans = 0, ans2 = 0;vector <pair <int, int> > e;for (int i = 1; i <= m; i ++) {int u, v;cin >> u >> v;if (u == v) ans ++;else {e.emplace_back(u, v);e.emplace_back(v, u);}}sort (e.begin(), e.end());
#include <bits/stdc++.h> using namespace std; using i64 = long long; int main() { cin.tie(nullptr) -> sync_with_stdio(false); int n, m; cin >> n >> m; int ans = 0, ans2 = 0; vector <pair <int, int> > e; for (int i = 1; i <= m; i ++) { int u, v; cin >> u >> v; if (u == v) ans ++; else { e.emplace_back(u, v); e.emplace_back(v, u); } } sort (e.begin(), e.end()); for (int i = 0; i < e.size();) { int j = i + 1; while (e[i] == e[j] && j < e.size()) ans2 ++, j ++; i = j; } cout << ans2 / 2 + ans << '\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Make it Simple |
User | Drifty |
Language | C++ 17 (gcc 12.2) |
Score | 300 |
Code Size | 680 Byte |
Status | AC |
Exec Time | 144 ms |
Memory | 11540 KiB |
Compile Error
Main.cpp: In function ‘int main()’: Main.cpp:22: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] 22 | for (int i = 0; i < e.size();) { | ~~^~~~~~~~~~ Main.cpp:24:34: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::pair<int, int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare] 24 | while (e[i] == e[j] && j < e.size()) ans2 ++, j ++; | ~~^~~~~~~~~~
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_n_small_00.txt, 01_n_small_01.txt, 01_n_small_02.txt, 01_n_small_03.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 03_corner_00.txt, 03_corner_01.txt, 03_corner_02.txt, 03_corner_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3460 KiB |
00_sample_01.txt | AC | 1 ms | 3484 KiB |
00_sample_02.txt | AC | 1 ms | 3604 KiB |
01_n_small_00.txt | AC | 77 ms | 11436 KiB |
01_n_small_01.txt | AC | 62 ms | 11444 KiB |
01_n_small_02.txt | AC | 98 ms | 11380 KiB |
01_n_small_03.txt | AC | 53 ms | 11404 KiB |
02_random_00.txt | AC | 85 ms | 11308 KiB |
02_random_01.txt | AC | 83 ms | 11400 KiB |
02_random_02.txt | AC | 144 ms | 11380 KiB |
02_random_03.txt | AC | 144 ms | 11444 KiB |
02_random_04.txt | AC | 122 ms | 11376 KiB |
02_random_05.txt | AC | 85 ms | 11440 KiB |
02_random_06.txt | AC | 143 ms | 11488 KiB |
02_random_07.txt | AC | 143 ms | 11420 KiB |
03_corner_00.txt | AC | 105 ms | 11540 KiB |
03_corner_01.txt | AC | 143 ms | 11380 KiB |
03_corner_02.txt | AC | 43 ms | 3600 KiB |
03_corner_03.txt | AC | 42 ms | 3480 KiB |