Submission #1074909

# Submission time Handle Problem Language Result Execution time Memory
1074909 2024-08-25T16:28:26 Z bleahbleah Closing Time (IOI23_closing) C++17
Compilation error
0 ms 0 KB
#include "closing.h"

#include <vector>
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;

#define sz(x) ((int)(x).size())

const int nmax = 2e5 + 5;

int dx[nmax], dy[nmax], p[nmax];
vector<pii> g[nmax];

void filld(int node, int f, int *d) {
   p[node] = f;
   for(auto [x, c] : g[node]) {
      if(x == f) continue;
      d[x] = d[node] + c;
      filld(x, node);
   }
   return;
}

int separate(int N, int S) {
   vector<pii> s;
   for(int i = 0; i < N; i++) {
      s.emplace_back(i, 1);
      s.emplace_back(i, 2);
   }
   sort(all(s), [&](auto a, auto b) {
      a.first = (a.second == 1? dx[a.first] : dy[a.first]);
      b.first = (b.second == 1? dx[b.first] : dy[b.first]);
      return a.first < b.first;
   });
   
   vector<int> occ(N, 0);
   int cnt = 0;
   for(auto [x, t] : s) {
      if(occ[x]) continue;
      x = (t == 1? dx[x] : dy[x]);
      if(S < x) break;
      S -= x;
      occ[x] = 1;
      cnt++;
   }
   
   return cnt;
}



int max_score(int N, int X, int Y, long long S, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
   for(int i = 0; i < sz(U); i++) {
      g[U[i]].emplace_back(V[i], W[i]);
      g[V[i]].emplace_back(U[i], W[i]);
   }
   
   filld(X, X, dx);
   filld(Y, Y, dy);
   
   int opt1 = separate(N, S);
   return opt1;
}

Compilation message

closing.cpp:13:8: error: 'pii' was not declared in this scope
   13 | vector<pii> g[nmax];
      |        ^~~
closing.cpp:13:11: error: template argument 1 is invalid
   13 | vector<pii> g[nmax];
      |           ^
closing.cpp:13:11: error: template argument 2 is invalid
closing.cpp: In function 'void filld(int, int, int*)':
closing.cpp:17:28: error: 'begin' was not declared in this scope
   17 |    for(auto [x, c] : g[node]) {
      |                            ^
closing.cpp:17:28: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from closing.cpp:4:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from closing.cpp:4:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
closing.cpp:17:28: error: 'end' was not declared in this scope
   17 |    for(auto [x, c] : g[node]) {
      |                            ^
closing.cpp:17:28: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from closing.cpp:4:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from closing.cpp:4:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
closing.cpp: In function 'int separate(int, int)':
closing.cpp:26:11: error: 'pii' was not declared in this scope
   26 |    vector<pii> s;
      |           ^~~
closing.cpp:26:14: error: template argument 1 is invalid
   26 |    vector<pii> s;
      |              ^
closing.cpp:26:14: error: template argument 2 is invalid
closing.cpp:28:9: error: request for member 'emplace_back' in 's', which is of non-class type 'int'
   28 |       s.emplace_back(i, 1);
      |         ^~~~~~~~~~~~
closing.cpp:29:9: error: request for member 'emplace_back' in 's', which is of non-class type 'int'
   29 |       s.emplace_back(i, 2);
      |         ^~~~~~~~~~~~
closing.cpp:5:20: error: request for member 'begin' in 's', which is of non-class type 'int'
    5 | #define all(x) (x).begin(),(x).end()
      |                    ^~~~~
closing.cpp:31:9: note: in expansion of macro 'all'
   31 |    sort(all(s), [&](auto a, auto b) {
      |         ^~~
closing.cpp:5:32: error: request for member 'end' in 's', which is of non-class type 'int'
    5 | #define all(x) (x).begin(),(x).end()
      |                                ^~~
closing.cpp:31:9: note: in expansion of macro 'all'
   31 |    sort(all(s), [&](auto a, auto b) {
      |         ^~~
closing.cpp:39:22: error: 'begin' was not declared in this scope
   39 |    for(auto [x, t] : s) {
      |                      ^
closing.cpp:39:22: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from closing.cpp:4:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from closing.cpp:4:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
closing.cpp:39:22: error: 'end' was not declared in this scope
   39 |    for(auto [x, t] : s) {
      |                      ^
closing.cpp:39:22: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from closing.cpp:4:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from closing.cpp:4:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:55:15: error: request for member 'emplace_back' in 'g[U.std::vector<int>::operator[](((std::vector<int>::size_type)i))]', which is of non-class type 'int'
   55 |       g[U[i]].emplace_back(V[i], W[i]);
      |               ^~~~~~~~~~~~
closing.cpp:56:15: error: request for member 'emplace_back' in 'g[V.std::vector<int>::operator[](((std::vector<int>::size_type)i))]', which is of non-class type 'int'
   56 |       g[V[i]].emplace_back(U[i], W[i]);
      |               ^~~~~~~~~~~~