//記得跳題
//#pragma GCC optimize("O4,unroll_loops")
//#pragma GCC target("avx2")
#include<iostream>
#include<array>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<iomanip>
#include<bitset>
#include<tuple>
#include<random>
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define INF (ll)(2e18)
#define F first
#define S second
#define endl "\n"
#define AC ios::sync_with_stdio(0);
using namespace std;
vector<pair<int, int> > e[200005];
vector<pair<int, int> > ans;
void dfs(int now, int f,int up){
if (up != -1) {
ans.pb({now, up});
}
for (auto i:e[now]) if (i.F != f) {
dfs(i.F, now, i.S);
}
}
signed main(){
AC;
int n, m; cin >> n >> m;
FOR (i, 0, m) {
int a, b; cin >> a >> b;
e[a].pb({b, 0});
e[b].pb({a, 1});
}
dfs(1, 0, -1);
cout << ans.size() << endl;
for (auto i:ans) {
cout << i.F << " " << i.S << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
344 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
16076 KB |
Output is correct |
2 |
Correct |
137 ms |
16764 KB |
Output is correct |
3 |
Correct |
66 ms |
11548 KB |
Output is correct |
4 |
Correct |
141 ms |
16712 KB |
Output is correct |
5 |
Correct |
141 ms |
16840 KB |
Output is correct |
6 |
Correct |
214 ms |
16780 KB |
Output is correct |
7 |
Correct |
140 ms |
16776 KB |
Output is correct |
8 |
Correct |
130 ms |
14364 KB |
Output is correct |
9 |
Correct |
138 ms |
16860 KB |
Output is correct |
10 |
Correct |
149 ms |
16772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
344 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |