//#define LOCAL
#include <bits/stdc++.h>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 1010101
#define MAXQ 101010
#define INF 1'000'000'100'000'000'000
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define MOD 1000000007
#define TC 1
#ifdef LOCAL
#define DEBUG(a) cout<<a
#define TEST true
#else
#define DEBUG(...) 1234
#define TEST false
#endif
vector<int> adj[MAX];
vector<pii> ansv;
int vis[MAX];
void dfs(int x) {
vis[x] = 1;
for (auto v : adj[x]) {
if (vis[v]) continue;
ansv.emplace_back(x, v);
dfs(v);
ansv.emplace_back(x, v);
}
}
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int N, M;
cin >> N >> M;
int i, j, a, b;
for (i = 0; i < M; i++) {
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for (i = 0; i < N; i++) {
memset(vis, 0, sizeof(vis));
dfs(i);
}
cout << ansv.size() << ln;
for (i = 0; i < ansv.size(); i++) {
for (j = 0; j < N; j++) {
if (j == ansv[i].first || j == ansv[i].second) cout << 1 << bb;
else cout << 0 << bb;
}
cout << ln;
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:54:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for (i = 0; i < ansv.size(); i++) {
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
27996 KB |
Output is correct |
2 |
Correct |
4 ms |
28124 KB |
Output is correct |
3 |
Correct |
4 ms |
27996 KB |
Output is correct |
4 |
Partially correct |
89 ms |
32032 KB |
Partially correct |
5 |
Partially correct |
95 ms |
32548 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
27996 KB |
Output is correct |
2 |
Correct |
4 ms |
27996 KB |
Output is correct |
3 |
Correct |
4 ms |
27996 KB |
Output is correct |
4 |
Incorrect |
6 ms |
27996 KB |
If people start at 0 and 1, then they can avoid each other |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
27996 KB |
Output is correct |
2 |
Correct |
5 ms |
27996 KB |
Output is correct |
3 |
Correct |
5 ms |
27996 KB |
Output is correct |
4 |
Partially correct |
16 ms |
28636 KB |
Partially correct |
5 |
Partially correct |
84 ms |
32200 KB |
Partially correct |
6 |
Partially correct |
79 ms |
32272 KB |
Partially correct |
7 |
Partially correct |
25 ms |
29268 KB |
Partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
27996 KB |
Output is correct |
2 |
Correct |
4 ms |
28124 KB |
Output is correct |
3 |
Correct |
4 ms |
27996 KB |
Output is correct |
4 |
Partially correct |
89 ms |
32032 KB |
Partially correct |
5 |
Partially correct |
95 ms |
32548 KB |
Partially correct |
6 |
Correct |
4 ms |
27996 KB |
Output is correct |
7 |
Correct |
5 ms |
27996 KB |
Output is correct |
8 |
Correct |
5 ms |
27996 KB |
Output is correct |
9 |
Partially correct |
16 ms |
28636 KB |
Partially correct |
10 |
Partially correct |
84 ms |
32200 KB |
Partially correct |
11 |
Partially correct |
79 ms |
32272 KB |
Partially correct |
12 |
Partially correct |
25 ms |
29268 KB |
Partially correct |
13 |
Correct |
5 ms |
27996 KB |
Output is correct |
14 |
Correct |
4 ms |
27996 KB |
Output is correct |
15 |
Correct |
4 ms |
27992 KB |
Output is correct |
16 |
Partially correct |
77 ms |
32128 KB |
Partially correct |
17 |
Partially correct |
85 ms |
32208 KB |
Partially correct |
18 |
Correct |
4 ms |
27996 KB |
Output is correct |
19 |
Correct |
5 ms |
28132 KB |
Output is correct |
20 |
Partially correct |
15 ms |
28700 KB |
Partially correct |
21 |
Partially correct |
81 ms |
32116 KB |
Partially correct |
22 |
Partially correct |
86 ms |
32384 KB |
Partially correct |
23 |
Partially correct |
26 ms |
29272 KB |
Partially correct |
24 |
Correct |
6 ms |
27996 KB |
Output is correct |
25 |
Incorrect |
5 ms |
27996 KB |
If people start at 0 and 2, then they can avoid each other |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
27996 KB |
Output is correct |
2 |
Correct |
4 ms |
28124 KB |
Output is correct |
3 |
Correct |
4 ms |
27996 KB |
Output is correct |
4 |
Partially correct |
89 ms |
32032 KB |
Partially correct |
5 |
Partially correct |
95 ms |
32548 KB |
Partially correct |
6 |
Correct |
4 ms |
27996 KB |
Output is correct |
7 |
Correct |
4 ms |
27996 KB |
Output is correct |
8 |
Correct |
4 ms |
27996 KB |
Output is correct |
9 |
Incorrect |
6 ms |
27996 KB |
If people start at 0 and 1, then they can avoid each other |
10 |
Halted |
0 ms |
0 KB |
- |