답안 #418030

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
418030 2021-06-04T22:33:34 Z Hegdahl Simurgh (IOI17_simurgh) C++17
0 / 100
36 ms 304 KB
#include <bits/stdc++.h>
#include "simurgh.h"
#define ar array
using namespace std;
using ld = long double;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

const int mxN = 500;
int boss[mxN], under[mxN];

int find(int i) {
  return i == boss[i] ? i : boss[i] = find(boss[i]);
}

bool unite(int i, int j) {
  i = find(i), j = find(j);
  if (i == j) return false;
  if (under[i] < under[j]) swap(i, j);
  under[i] += under[j];
  boss[j] = i;
  return true;
}

int n;
vector<ar<int, 2>> e;


vector<int> mst(const vector<ld> &w) {
  iota(boss, boss+n, 0);
  fill(under, under+n, 1);

  vector<int> eid(e.size());
  iota(eid.begin(), eid.end(), 0);
  sort(eid.begin(), eid.end(), [&](int i, int j) { return w[i] > w[j]; });

  vector<int> ans;
  for (int i : eid)
    if (unite(e[i][0], e[i][1]))
      ans.push_back(i);
  return ans;
}

vector<int> find_roads(int _n, vector<int> u, vector<int> v) {
  n = _n;
  const int m = u.size();
  e.resize(m);
  for (int mm = 0; mm < m; ++mm) e[mm] = {u[mm], v[mm]};

  ld expect = (ld)n/m;

  vector<ld> score(m, 1);
  for (int rep = 0; rep < 8000; ++rep) {
    vector<ld> w = score;
    for (int i = 0; i < m; ++i) w[i] += rng()%100;
    auto t = mst(w);
    int common = count_common_roads(t);

    for (int i : t) score[i] += (common-expect);
  }

  return mst(score);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB correct
2 Incorrect 36 ms 304 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 204 KB WA in grader: NO
2 Halted 0 ms 0 KB -