# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
704863 |
2023-03-03T05:56:45 Z |
browntoad |
Naboj (COCI22_naboj) |
C++14 |
|
345 ms |
15632 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n+1)
#define RREP(i, n) for (int i=(n)-1; i>=0; i--)
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
const ll maxn = 2e5+5;
int n, m;
vector<int> graph[maxn];
vector<int> in(maxn);
vector<bool> occ(maxn);
void inp(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin>>n>>m;
REP(i, m){
int u, v; cin>>u>>v;
graph[v].pb(u);
in[u]++;
}
}
void solve(){
queue<int> qu;
REP1(i, n){
if (in[i] == 0) qu.push(i);
}
vector<int> topo;
while(qu.size()){
int x=qu.front(); qu.pop();
occ[x]=1;
topo.pb(x);
REP(i, SZ(graph[x])){
in[graph[x][i]]--;
if (in[graph[x][i]] == 0){
qu.push(graph[x][i]);
}
}
}
bool gg=0;
REP1(i, n){
if (occ[i] == 0){
gg=1;
break;
}
}
if (gg) {
cout<<-1<<endl;
return;
}
assert(SZ(topo)==n);
RREP(i, n){
cout<<topo[i]<<' '<<1<<endl;
}
}
signed main(){
inp();
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6612 KB |
Output is correct |
2 |
Correct |
4 ms |
6612 KB |
Output is correct |
3 |
Correct |
4 ms |
6616 KB |
Output is correct |
4 |
Correct |
3 ms |
6556 KB |
Output is correct |
5 |
Correct |
4 ms |
6612 KB |
Output is correct |
6 |
Correct |
4 ms |
6620 KB |
Output is correct |
7 |
Correct |
3 ms |
6624 KB |
Output is correct |
8 |
Incorrect |
4 ms |
6624 KB |
Integer parameter [name=d] equals to 5, violates the range [0, 1] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
345 ms |
15632 KB |
Integer parameter [name=d] equals to 70214, violates the range [0, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6612 KB |
Output is correct |
2 |
Correct |
4 ms |
6612 KB |
Output is correct |
3 |
Correct |
4 ms |
6616 KB |
Output is correct |
4 |
Correct |
3 ms |
6556 KB |
Output is correct |
5 |
Correct |
4 ms |
6612 KB |
Output is correct |
6 |
Correct |
4 ms |
6620 KB |
Output is correct |
7 |
Correct |
3 ms |
6624 KB |
Output is correct |
8 |
Incorrect |
4 ms |
6624 KB |
Integer parameter [name=d] equals to 5, violates the range [0, 1] |
9 |
Halted |
0 ms |
0 KB |
- |