제출 #1308779

#제출 시각아이디문제언어결과실행 시간메모리
1308779sagsterBitaro’s Party (JOI18_bitaro)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 100010, B = 300; vector<pair<int,int>> merge(vector<pair<int,int>> &tobe, vector<pair<int,int>> &merged){ vector<pair<int,int>> res; vector<int> jafoi(N); int p1 = 0, p2 = 0, size1 = tobe.size(), size2 = merged.size(), ct = 0; while(ct < B && (p1 < size1 || p2 < size2)){ if(p2 == size2){ // cout << "1 " << p1 << " " << p2 << endl; if(!jafoi[tobe[p1].second]){ jafoi[tobe[p1].second] = 1; res.push_back(tobe[p1]); ct++; // cout << "ebaaa1 " << res[res.size()-1].first << " " << res[res.size()-1].second << endl; } p1++; } else if(p1 == size1){ // cout << "2 " << p1 << " " << p2 << endl; if(!jafoi[merged[p2].second]){ jafoi[merged[p2].second] = 1; res.push_back({merged[p2].first + 1, merged[p2].second}); ct++; // cout << "ebaaa2 " << res[res.size()-1].first << " " << res[res.size()-1].second << endl; } p2++; } else if(tobe[p1].first > merged[p2].first + 1){ // cout << "3 " << p1 << " " << p2 << endl; if(!jafoi[tobe[p1].second]){ jafoi[tobe[p1].second] = 1; res.push_back(tobe[p1]); ct++; // cout << "ebaaa3 " << res[res.size()-1].first << " " << res[res.size()-1].second << endl; } p1++; } else{ // cout << "4 " << p1 << " " << p2 << endl; if(!jafoi[merged[p2].second]){ jafoi[merged[p2].second] = 1; res.push_back({merged[p2].first + 1, merged[p2].second}); ct++; // cout << "ebaaa4 " << res[res.size()-1].first << " " << res[res.size()-1].second << endl; } p2++; } } return res; } signed main(){ int n, m, q; cin >> n >> m >> q; vector<vector<int>> nei(n, vector<int>(0)); // .f = dist ,,, .s = id for(int i = 0; i < m; i++){ int a, b; cin >> a >> b; nei[a-1].push_back(b-1); } vector<vector<pair<int,int>>> dist(n, vector<pair<int,int>>(0)); for(int i = 0; i < n; i++) dist[i].push_back({(int)0,i}); for(int i = 0; i < n; i++){ for(auto v : nei[i]){ dist[v] = merge(dist[v], dist[i]); } } // for(int i = 0; i < n; i++){ // cout << i+1 << ":\n"; // for(auto [distance, frie] : dist[i]){ // cout << distance << " " << frie+1 << endl; // } // cout << "\n\n"; // } for(int i = 0; i < q; i++){ int cid, bloq; cin >> cid >> bloq; cid--; vector<bool> block(N); for(int j = 0; j < bloq;j++){ int x; cin >> x; block[x-1] = true; } // cout << "\n\noioi"; // for(int j = 0; j < n; j++) cout << block[j] << endl; // cout << "\n\n"; if(bloq >= B){ vector<pair<int,int>> maior(n); for(int j = 0; j < n; j++) maior[j] = {0,j}; for(int j = 0; j < cid; j++){ for(auto cur : nei[j]){ if(!block[maior[j].second] && maior[j].first + 1 > maior[cur].first){ maior[cur] = {maior[j].first + 1, maior[j].second}; // cout << j+1<< " atualizando " << cur+1 << " " << maior[cur].first << " "<< maior[cur].second+1 << "\n"; } } } if(!block[maior[cid].second]) cout << maior[cid].first << "\n"; else cout << -1 << "\n"; } else{ // cout << cid+1 << " " << bloq << " "; bool a = true; for(auto [distance, frie] : dist[cid]){ if(!block[frie]){ cout << distance << endl; a = false; break; } } if(a) cout << -1 << endl; } } }

컴파일 시 표준 에러 (stderr) 메시지

bitaro.cpp:1:26: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h> using namespace std; #define int long long const int
      |                          ^~~~~
bitaro.cpp:2:2: error: 'N' does not name a type
    2 |  N = 100010, B = 300;
      |  ^
bitaro.cpp:4:8: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    4 | vector<pair<int,int>> merge(vector<pair<int,int>> &tobe, vector<pair<int,int>> &merged){
      |        ^~~~
      |        std::pair
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from bitaro.cpp:1:
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
bitaro.cpp:4:8: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    4 | vector<pair<int,int>> merge(vector<pair<int,int>> &tobe, vector<pair<int,int>> &merged){
      |        ^~~~
      |        std::pair
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
bitaro.cpp:4:8: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    4 | vector<pair<int,int>> merge(vector<pair<int,int>> &tobe, vector<pair<int,int>> &merged){
      |        ^~~~
      |        std::pair
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
bitaro.cpp:4:8: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    4 | vector<pair<int,int>> merge(vector<pair<int,int>> &tobe, vector<pair<int,int>> &merged){
      |        ^~~~
      |        std::pair
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
bitaro.cpp:4:8: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    4 | vector<pair<int,int>> merge(vector<pair<int,int>> &tobe, vector<pair<int,int>> &merged){
      |        ^~~~
      |        std::pair
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
bitaro.cpp:4:8: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    4 | vector<pair<int,int>> merge(vector<pair<int,int>> &tobe, vector<pair<int,int>> &merged){
      |        ^~~~
      |        std::pair
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
bitaro.cpp:4:8: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    4 | vector<pair<int,int>> merge(vector<pair<int,int>> &tobe, vector<pair<int,int>> &merged){
      |        ^~~~
      |        std::pair
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
bitaro.cpp:4:8: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    4 | vector<pair<int,int>> merge(vector<pair<int,int>> &tobe, vector<pair<int,int>> &merged){
      |        ^~~~
      |        std::pair
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
bitaro.cpp:4:8: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    4 | vector<pair<int,int>> merge(vector<pair<int,int>> &tobe, vector<pair<int,int>> &merged){
      |        ^~~~
      |        std::pair
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
bitaro.cpp:4:1: error: 'vector' does not name a type
    4 | vector<pair<int,int>> merge(vector<pair<int,int>> &tobe, vector<pair<int,int>> &merged){
      | ^~~~~~
bitaro.cpp: In function 'int main()':
bitaro.cpp:54:22: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   54 |         int n, m, q; cin >> n >> m >> q;
      |                      ^~~
      |                      std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:146:
/usr/include/c++/13/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
bitaro.cpp:55:16: error: 'vector' was not declared in this scope
   55 |         vector<vector<int>> nei(n, vector<int>(0)); // .f = dist ,,, .s = id
      |                ^~~~~~
bitaro.cpp:55:16: note: suggested alternatives:
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/13/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
bitaro.cpp:55:23: error: expected primary-expression before 'int'
   55 |         vector<vector<int>> nei(n, vector<int>(0)); // .f = dist ,,, .s = id
      |                       ^~~
bitaro.cpp:58:17: error: 'nei' was not declared in this scope
   58 |                 nei[a-1].push_back(b-1);
      |                 ^~~
bitaro.cpp:60:23: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   60 |         vector<vector<pair<int,int>>> dist(n, vector<pair<int,int>>(0));
      |                       ^~~~
      |                       std::pair
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
bitaro.cpp:60:28: error: expected primary-expression before 'int'
   60 |         vector<vector<pair<int,int>>> dist(n, vector<pair<int,int>>(0));
      |                            ^~~
bitaro.cpp:61:36: error: 'dist' was not declared in this scope
   61 |         for(int i = 0; i < n; i++) dist[i].push_back({(int)0,i});
      |                                    ^~~~
bitaro.cpp:63:30: error: 'nei' was not declared in this scope
   63 |                 for(auto v : nei[i]){
      |                              ^~~
bitaro.cpp:64:25: error: 'dist' was not declared in this scope
   64 |                         dist[v] = merge(dist[v], dist[i]);
      |                         ^~~~
bitaro.cpp:64:35: error: 'merge' was not declared in this scope
   64 |                         dist[v] = merge(dist[v], dist[i]);
      |                                   ^~~~~
bitaro.cpp:64:35: note: suggested alternatives:
In file included from /usr/include/c++/13/algorithm:73:
/usr/include/c++/13/pstl/glue_algorithm_defs.h:417:1: note:   'std::merge'
  417 | merge(_ExecutionPolicy&& __exec, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
      | ^~~~~
In file included from /usr/include/c++/13/algorithm:63:
/usr/include/c++/13/bits/ranges_algo.h:2540:31: note:   'std::ranges::merge'
 2540 |   inline constexpr __merge_fn merge{};
      |                               ^~~~~
bitaro.cpp:78:24: error: expected primary-expression before 'bool'
   78 |                 vector<bool> block(N);
      |                        ^~~~
bitaro.cpp:81:25: error: 'block' was not declared in this scope; did you mean 'std::filesystem::file_type::block'?
   81 |                         block[x-1] = true;
      |                         ^~~~~
      |                         std::filesystem::file_type::block
In file included from /usr/include/c++/13/filesystem:48,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:200:
/usr/include/c++/13/bits/fs_fwd.h:80:7: note: 'std::filesystem::file_type::block' declared here
   80 |       block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
      |       ^~~~~
bitaro.cpp:87:28: error: 'B' was not declared in this scope
   87 |                 if(bloq >= B){
      |                            ^
bitaro.cpp:88:37: error: expected primary-expression before 'int'
   88 |                         vector<pair<int,int>> maior(n);
      |                                     ^~~
bitaro.cpp:89:52: error: 'maior' was not declared in this scope
   89 |                         for(int j = 0; j < n; j++) maior[j] = {0,j};
      |                                                    ^~~~~
bitaro.cpp:91:48: error: 'nei' was not declared in this scope
   91 |                                 for(auto cur : nei[j]){
      |                                                ^~~
bitaro.cpp:92:45: error: 'block' was not declared in this scope; did you mean 'std::filesystem::file_type::block'?
   92 |                                         if(!block[maior[j].second] && maior[j].first + 1 > maior[cur].first){
      |                                             ^~~~~
      |                                             std::filesystem::file_type::block
/usr/include/c++/13/bits/fs_fwd.h:80:7: note: 'std::filesystem::file_type::block' declared here
   80 |       block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
      |       ^~~~~
bitaro.cpp:92:51: error: 'maior' was not declared in this scope
   92 |                                         if(!block[maior[j].second] && maior[j].first + 1 > maior[cur].first){
      |                                                   ^~~~~
bitaro.cpp:98:29: error: 'block' was not declared in this scope; did you mean 'std::filesystem::file_type::block'?
   98 |                         if(!block[maior[cid].second]) cout << maior[cid].first << "\n";
      |                             ^~~~~
      |                             std::filesystem::file_type::block
/usr/include/c++/13/bits/fs_fwd.h:80:7: note: 'std::filesystem::file_type::block' declared here
   80 |       block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
      |       ^~~~~
bitaro.cpp:98:35: error: 'maior' was not declared in this scope
   98 |                         if(!block[maior[cid].second]) cout << maior[cid].first << "\n";
      |                                   ^~~~~
bitaro.cpp:98:55: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   98 |                         if(!block[maior[cid].second]) cout << maior[cid].first << "\n";
      |                                                       ^~~~
      |                                                       std::cout
/usr/include/c++/13/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
bitaro.cpp:99:30: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   99 |                         else cout << -1 << "\n";
      |                              ^~~~
      |                              std::cout
/usr/include/c++/13/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
bitaro.cpp:104:53: error: 'dist' was not declared in this scope
  104 |                         for(auto [distance, frie] : dist[cid]){
      |                                                     ^~~~
bitaro.cpp:105:37: error: 'block' was not declared in this scope; did you mean 'std::filesystem::file_type::block'?
  105 |                                 if(!block[frie]){
      |                                     ^~~~~
      |                                     std::filesystem::file_type::block
/usr/include/c++/13/bits/fs_fwd.h:80:7: note: 'std::filesystem::file_type::block' declared here
   80 |       block = 4, character = 5, fifo = 6, socket = 7, unknown = 8
      |       ^~~~~
bitaro.cpp:106:41: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
  106 |                                         cout << distance << endl;
      |                                         ^~~~
      |                                         std::cout
/usr/include/c++/13/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
bitaro.cpp:106:61: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
  106 |                                         cout << distance << endl;
      |                                                             ^~~~
      |                                                             std::endl
In file included from /usr/include/c++/13/bits/unique_ptr.h:42,
                 from /usr/include/c++/13/memory:78,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:56:
/usr/include/c++/13/ostream:735:5: note: 'std::endl' declared here
  735 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
bitaro.cpp:111:31: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
  111 |                         if(a) cout << -1 << endl;
      |                               ^~~~
      |                               std::cout
/usr/include/c++/13/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
bitaro.cpp:111:45: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
  111 |                         if(a) cout << -1 << endl;
      |                                             ^~~~
      |                                             std::endl
/usr/include/c++/13/ostream:735:5: note: 'std::endl' declared here
  735 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~