| 18035 | 2025-09-25 17:32:34 | algopro | Testnevelés óra | cpp17 | Forditási hiba |
// UUID: d7c41def-b65f-40a4-9840-dce53c03dd9c
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<vector<int>> graph(n);
vector<int> be(n);
for (int i=0; i<n; i++) {
int a,b;
cin >> a >> b;
be[b-1]++;
graph[a-1].push_back(b-1);
}
for (int i=0; i<n; i++) {
if (be[i]==0) {
av.push_back(i);
bv.push_back(i);
}
}
vector<int> av;
vector<int> bv;
int k=0;
bool more=false;
while (k<v.size()) {
if (v.size()-k>0) {
bv[k]=av[k+1];
b[k+1]=av[k];
more=true;
}
for (int i:graph[k]) {
be[i]--;
if (be[i]==0) {
av.push_back(be);
bv.push_back(be);
}
}
k++;
}
if (k<n) {
cout << 0;
}
else {
if (more) {
cout << 2 << "\n";
for (int i=0; i<n; i++) {
cout << av[i] << " ";
}
cout << "\n";
for (int i=0; i<n; i++) {
cout << bv[i] << " ";
}
}
else {
cout << 1 << "\n";
for (int i=0; i<n; i++) {
cout << av[i] << " ";
}
}
}
}
open /var/local/lib/isolate/421/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:20:13: error: 'av' was not declared in this scope
20 | av.push_back(i);
| ^~
main.cpp:21:13: error: 'bv' was not declared in this scope; did you mean 'be'?
21 | bv.push_back(i);
| ^~
| be
main.cpp:28:14: error: 'v' was not declared in this scope
28 | while (k<v.size()) {
| ^
main.cpp:31:13: error: 'b' was not declared in this scope
31 | b[k+1]=av[k];
| ^
main.cpp:37:29: error: no matching function for call to 'std::vector<int>::push_back(std::vector<int>&)'
37 | av.push_back(be);
| ~~~~~~~~~~~~^~~~
In file included from /usr/include/c++/12/vector:64,
from /usr/include/c++/12/functional:62,
from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:71,
from main.cpp:2:
/usr/include/c++/12/bits/stl_vector.h:1276:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
1276 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/12/bits/stl_vector.h:1276:35: note: no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<int>::value_type&' {aka 'const int&'}
1276 | push_back(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/12/bits/stl_vector.h:1293:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
1293 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/12/bits/stl_vector.h:1293:30: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
1293 | push_back(value_type&& __x)
| ~~~~~~~~~~~~~^~...