Submission #852265

# Submission time Handle Problem Language Result Execution time Memory
852265 2023-09-21T14:03:24 Z Trisanu_Das Naboj (COCI22_naboj) C++17
Compilation error
0 ms 0 KB
#incldue <bits/stdc++.h>
using namespace std;

int main(){
  int n, m; cin >> n >> m;
  int deg[n + 1], u, v; memset(deg, 0, sizeof(deg));
  vector<int> adj[n + 1];
  while(m--){
    cin >> v >> u;
    adj[u].push_back(u); deg[u]++;
  }
  vector<int> toposort;
  queue<int> q;
  for(int i = 1; i < n + 1; i++) if(deg[i] == 0) q.push(i);
  while(!q.empty()){
    int u = q.front(); q.pop;
    toposort.push_back(u);
    for(v : adj[u]){
      deg[v]--; if(deg[v] == 0) q.push_back(v);
    }
  }
  if(toposort.size() != n) cout << -1 << '\n';
  else{
    cout << n << '\n';
    for(auto u : toposort) cout << u << ' ' << 0 << '\n';
  }
}

Compilation message

naboj.cpp:1:2: error: invalid preprocessing directive #incldue; did you mean #include?
    1 | #incldue <bits/stdc++.h>
      |  ^~~~~~~
      |  include
naboj.cpp: In function 'int main()':
naboj.cpp:5:13: error: 'cin' was not declared in this scope
    5 |   int n, m; cin >> n >> m;
      |             ^~~
naboj.cpp:1:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | #incldue <bits/stdc++.h>
naboj.cpp:6:25: error: 'memset' was not declared in this scope
    6 |   int deg[n + 1], u, v; memset(deg, 0, sizeof(deg));
      |                         ^~~~~~
naboj.cpp:1:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
  +++ |+#include <cstring>
    1 | #incldue <bits/stdc++.h>
naboj.cpp:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> adj[n + 1];
      |   ^~~~~~
naboj.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | #incldue <bits/stdc++.h>
naboj.cpp:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> adj[n + 1];
      |          ^~~
naboj.cpp:10:5: error: 'adj' was not declared in this scope
   10 |     adj[u].push_back(u); deg[u]++;
      |     ^~~
naboj.cpp:12:10: error: expected primary-expression before 'int'
   12 |   vector<int> toposort;
      |          ^~~
naboj.cpp:13:3: error: 'queue' was not declared in this scope
   13 |   queue<int> q;
      |   ^~~~~
naboj.cpp:1:1: note: 'std::queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
  +++ |+#include <queue>
    1 | #incldue <bits/stdc++.h>
naboj.cpp:13:9: error: expected primary-expression before 'int'
   13 |   queue<int> q;
      |         ^~~
naboj.cpp:14:50: error: 'q' was not declared in this scope
   14 |   for(int i = 1; i < n + 1; i++) if(deg[i] == 0) q.push(i);
      |                                                  ^
naboj.cpp:15:10: error: 'q' was not declared in this scope
   15 |   while(!q.empty()){
      |          ^
naboj.cpp:17:5: error: 'toposort' was not declared in this scope
   17 |     toposort.push_back(u);
      |     ^~~~~~~~
naboj.cpp:18:11: error: found ':' in nested-name-specifier, expected '::'
   18 |     for(v : adj[u]){
      |           ^
      |           ::
naboj.cpp:18:9: error: 'v' is not a class, namespace, or enumeration
   18 |     for(v : adj[u]){
      |         ^
naboj.cpp:21:3: error: expected primary-expression before '}' token
   21 |   }
      |   ^
naboj.cpp:20:6: error: expected ';' before '}' token
   20 |     }
      |      ^
      |      ;
   21 |   }
      |   ~   
naboj.cpp:21:3: error: expected primary-expression before '}' token
   21 |   }
      |   ^
naboj.cpp:20:6: error: expected ')' before '}' token
   20 |     }
      |      ^
      |      )
   21 |   }
      |   ~   
naboj.cpp:18:8: note: to match this '('
   18 |     for(v : adj[u]){
      |        ^
naboj.cpp:21:3: error: expected primary-expression before '}' token
   21 |   }
      |   ^
naboj.cpp:22:6: error: 'toposort' was not declared in this scope
   22 |   if(toposort.size() != n) cout << -1 << '\n';
      |      ^~~~~~~~
naboj.cpp:22:28: error: 'cout' was not declared in this scope
   22 |   if(toposort.size() != n) cout << -1 << '\n';
      |                            ^~~~
naboj.cpp:22:28: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
naboj.cpp:24:5: error: 'cout' was not declared in this scope
   24 |     cout << n << '\n';
      |     ^~~~
naboj.cpp:24:5: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?