Submission #1074919

# Submission time Handle Problem Language Result Execution time Memory
1074919 2024-08-25T16:35:01 Z bleahbleah Closing Time (IOI23_closing) C++17
8 / 100
155 ms 43280 KB
#include "closing.h"

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

using ll = long long;
#define int ll

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

using pii = pair<int,int>;

const int nmax = 2e5 + 5;

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

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

int separate(int N, ll 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) {
      return (a.second == 1? dx[a.first] : dy[a.first]) < (b.second == 1? dx[b.first] : dy[b.first]);
   });
   
   vector<int> occ(N, 0);
   int cnt = 0;
   for(auto [x, t] : s) {
      if(occ[x]) continue;
      auto C = (t == 1? dx[x] : dy[x]);
      if(S < C) break;
      S -= C;
      occ[x] = 1;
      cnt++;
   }
   
   return cnt;
}



signed max_score(signed N, signed X, signed Y, long long S, std::vector<signed> U, std::vector<signed> V, std::vector<signed> W) {
   for(int i = 0; i <= N; i++) g[i].clear();
   
   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]);
   }
   
   dx[X] = dy[Y] = 0;
   filld(X, X, dx);
   filld(Y, Y, dy);
   
   int opt1 = separate(N, S);
   return opt1;
}

#undef int
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8792 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 146 ms 38084 KB Output is correct
2 Correct 155 ms 43280 KB Output is correct
3 Correct 76 ms 11344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Incorrect 1 ms 8796 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Incorrect 1 ms 8796 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 8796 KB Output is correct
2 Incorrect 1 ms 8796 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8792 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8792 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8792 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8792 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 8792 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -