Submission #976226

#TimeUsernameProblemLanguageResultExecution timeMemory
976226TsaganaCyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
// #include "cyberland.h"
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define vi vector<int>
#define pi pair<int, int >
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define mset multiset
#define F first
#define S second

using namespace std;

// START

struct country
{
  double cost[31];
};

country cnt[100001];
vector<pi> adj[100001];
vi ar;
int h, D;

int vs[100001];
vi takes(int s) {
  vi v;
  pq<int> q;
  q.push(s);
  while (!q.empty()) {
    s = q.top(); q.pop();
    for (auto i: adj[s]) {
      if (vs[i.S]) continue ;
      vs[i.S] = 1;
      if (!ar[i.S]) v.pb(i.S); 
      q.push(i.S);
    }
  }
  return v;
}
void dfs(int s, int k, double cos)
{
  if (k > D) return ;
  if (cnt[s].cost[k] <= cos) return ;
  cnt[s].cost[k] = cos;

  // cout << s << ' ' << k << ' ';
  // printf("%.12lf\n", cos);
  if (s == h) return ;
  for (auto i: adj[s]) {
    double c = i.F;
    int x = i.S;

    dfs(x, k, c + cos);
    if (ar[s] == 2 && k <= D) dfs(x, k + 1, c + (cos / 2.0));
  }
}
double solve(int N, int M, int K, int H, vi x, vi y, vi c, vi arr) {
  ar = arr;
  h = H; D = K;
  for (int i = 0; i < M; i++) {
    adj[x[i]].pb({c[i], y[i]});
    adj[y[i]].pb({c[i], x[i]});
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= K; j++) {
      cnt[i].cost[j] = 1e9;
    }
  }
  vi v = takes(0);
  for (auto i: v) {
    adj[0].pb({0, i});
  }
  dfs(0, 0, 0.0);

  double ans = cnt[H].cost[0];
  for (int i = 1; i <= K; i++) {
   if (ans > cnt[H].cost[i]) ans = cnt[H].cost[i];
  }
  return ans;
}

//END

signed main() {
  int T;
  assert(1 == scanf("%d", &T));
  while (T--){
    int N,M,K,H;
    assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H));
    std::vector<int> x(M);
    std::vector<int> y(M);
    std::vector<int> c(M);
    std::vector<int> arr(N);
    for (int i=0;i<N;i++)
      assert(1 == scanf("%d", &arr[i]));
    for (int i=0;i<M;i++)
      assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i]));
    printf("%.12lf\n", solve(N, M, K, H, x, y, c, arr));
  }
}

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cyberland.cpp:2:
cyberland.cpp: In function 'int main()':
cyberland.cpp:94:21: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   94 |   assert(1 == scanf("%d", &T));
      |                     ^~~~  ~~
      |                           |
      |                           long long int*
cyberland.cpp:94:23: note: format string is defined here
   94 |   assert(1 == scanf("%d", &T));
      |                      ~^
      |                       |
      |                       int*
      |                      %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cyberland.cpp:2:
cyberland.cpp:97:23: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   97 |     assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H));
      |                       ^~~~~~~~~~~~~~  ~~
      |                                       |
      |                                       long long int*
cyberland.cpp:97:25: note: format string is defined here
   97 |     assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H));
      |                        ~^
      |                         |
      |                         int*
      |                        %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cyberland.cpp:2:
cyberland.cpp:97:23: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   97 |     assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H));
      |                       ^~~~~~~~~~~~~~      ~~
      |                                           |
      |                                           long long int*
cyberland.cpp:97:28: note: format string is defined here
   97 |     assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H));
      |                           ~^
      |                            |
      |                            int*
      |                           %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cyberland.cpp:2:
cyberland.cpp:97:23: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   97 |     assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H));
      |                       ^~~~~~~~~~~~~~          ~~
      |                                               |
      |                                               long long int*
cyberland.cpp:97:31: note: format string is defined here
   97 |     assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H));
      |                              ~^
      |                               |
      |                               int*
      |                              %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cyberland.cpp:2:
cyberland.cpp:97:23: warning: format '%d' expects argument of type 'int*', but argument 5 has type 'long long int*' [-Wformat=]
   97 |     assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H));
      |                       ^~~~~~~~~~~~~~              ~~
      |                                                   |
      |                                                   long long int*
cyberland.cpp:97:35: note: format string is defined here
   97 |     assert(4 == scanf("%d %d %d\n%d", &N, &M, &K, &H));
      |                                  ~^
      |                                   |
      |                                   int*
      |                                  %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cyberland.cpp:2:
cyberland.cpp:103:25: warning: format '%d' expects argument of type 'int*', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type*' {aka 'long long int*'} [-Wformat=]
  103 |       assert(1 == scanf("%d", &arr[i]));
      |                         ^~~~
cyberland.cpp:103:27: note: format string is defined here
  103 |       assert(1 == scanf("%d", &arr[i]));
      |                          ~^
      |                           |
      |                           int*
      |                          %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cyberland.cpp:2:
cyberland.cpp:105:25: warning: format '%d' expects argument of type 'int*', but argument 2 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type*' {aka 'long long int*'} [-Wformat=]
  105 |       assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i]));
      |                         ^~~~~~~~~~
cyberland.cpp:105:27: note: format string is defined here
  105 |       assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i]));
      |                          ~^
      |                           |
      |                           int*
      |                          %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cyberland.cpp:2:
cyberland.cpp:105:25: warning: format '%d' expects argument of type 'int*', but argument 3 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type*' {aka 'long long int*'} [-Wformat=]
  105 |       assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i]));
      |                         ^~~~~~~~~~
cyberland.cpp:105:30: note: format string is defined here
  105 |       assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i]));
      |                             ~^
      |                              |
      |                              int*
      |                             %lld
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from cyberland.cpp:2:
cyberland.cpp:105:25: warning: format '%d' expects argument of type 'int*', but argument 4 has type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type*' {aka 'long long int*'} [-Wformat=]
  105 |       assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i]));
      |                         ^~~~~~~~~~
cyberland.cpp:105:33: note: format string is defined here
  105 |       assert(3 == scanf("%d %d %d", &x[i], &y[i], &c[i]));
      |                                ~^
      |                                 |
      |                                 int*
      |                                %lld
/usr/bin/ld: /tmp/cc3ROjbH.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccLGEHRD.o:cyberland.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc3ROjbH.o: in function `main':
grader.cpp:(.text.startup+0x696): undefined reference to `solve(int, int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status