답안 #692283

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
692283 2023-02-01T09:39:35 Z horiseun Two Transportations (JOI19_transportations) C++17
컴파일 오류
0 ms 0 KB
#include "Azer.h"
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <climits>
#include <algorithm>
using namespace std;

#define f first
#define s second

int n, dc, c, st, sn, re, idx, prev;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
vector<pair<int, int>> adj[2005];
vector<int> dist;
bool seen[2005];

void dijkstra(int curr, int val) {
  val += prev;
  prev = val;
  dist[curr] = val;
  seen[curr] = true;
  dc++;
  if (dc == n) return;
  for (auto [i, w] : adj[curr]) {
    if (dist[curr] + w < dist[i]) {
      dist[i] = dist[curr] + w;
      pq.push({dist[i], i});
    }
  }
  while (!pq.empty() && seen[pq.top().s]) {
    pq.pop();
  }
  if (pq.empty()) sn = 501;
  else sn = pq.top().f - prev;
  for (int i = 8; i >= 0; i--) {
    SendA((sn >> i) & 1);
  }
  if (pq.empty()) idx = 2000;
  else idx = pq.top().s;
}

void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C) {
  n = N;
  for (int i = 0; i < A; i++) {
    adj[U[i]].push_back({V[i], C[i]});
    adj[V[i]].push_back({U[i], C[i]});
  }
  dist.resize(n, 1e9);
  dijkstra(0, 0);
}

void ReceiveA(bool x) {
  if (st == 0) {
    re = (re << 1) + x;
    c++;
    if (c == 9) {
      c = 0;
      if (sn <= re) {
        for (int i = 10; i >= 0; i--) {
          SendA((idx >> i) & 1);
        }
        dijkstra(idx, sn);
        re = 0;
      } else {
        st = 1;
        idx = 0;
      }
    }
  } else {
    idx = (idx << 1) + x;
    c++;
    if (c == 11) {
      c = 0;
      st = 0;
      dijkstra(idx, re);
      re = 0;
    }
  }
}

vector<int> Answer() {
  return dist;
}
#include "Baijan.h"
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <climits>
#include <algorithm>
using namespace std;

#define f first
#define s second

int n, dc, c, st, sn, re, idx, prev;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
vector<pair<int, int>> adj[2005];
vector<int> dist;
bool seen[2005];

void dijkstra(int curr, int val) {
  val += prev;
  prev = val;
  dist[curr] = val;
  seen[curr] = true;
  dc++;
  if (dc == n) return;
  for (auto [i, w] : adj[curr]) {
    if (dist[curr] + w < dist[i]) {
      dist[i] = dist[curr] + w;
      pq.push({dist[i], i});
    }
  }
  while (!pq.empty() && seen[pq.top().s]) {
    pq.pop();
  }
  if (pq.empty()) sn = 501;
  else sn = pq.top().f - prev;
  for (int i = 8; i >= 0; i--) {
    SendB((sn >> i) & 1);
  }
  if (pq.empty()) idx = 2000;
  else idx = pq.top().s;
}

void InitB(int N, int B, vector<int> S, vector<int> T, vector<int> D) {
  n = N;
  for (int i = 0; i < B; i++) {
    adj[S[i]].push_back({T[i], D[i]});
    adj[T[i]].push_back({S[i], D[i]});
  }
  dist.resize(n, 1e9);
  dijkstra(0, 0);
}

void ReceiveB(bool y) {
  if (st == 0) {
    re = (re << 1) + y;
    c++;
    if (c == 9) {
      c = 0;
      if (sn < re) {
        for (int i = 10; i >= 0; i--) {
          SendB((idx >> i) & 1);
        }
        dijkstra(idx, sn);
        re = 0;
      } else {
        st = 1;
        idx = 0;
      }
    }
  } else {
    idx = (idx << 1) + y;
    c++;
    if (c == 11) {
      c = 0;
      st = 0;
      dijkstra(idx, re);
      re = 0;
    }
  }
}

Compilation message

Azer.cpp: In function 'void dijkstra(int, int)':
Azer.cpp:20:10: error: reference to 'prev' is ambiguous
   20 |   val += prev;
      |          ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/vector:60,
                 from Azer.h:6,
                 from Azer.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Azer.cpp:13:32: note:                 'int prev'
   13 | int n, dc, c, st, sn, re, idx, prev;
      |                                ^~~~
Azer.cpp:21:3: error: reference to 'prev' is ambiguous
   21 |   prev = val;
      |   ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/vector:60,
                 from Azer.h:6,
                 from Azer.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Azer.cpp:13:32: note:                 'int prev'
   13 | int n, dc, c, st, sn, re, idx, prev;
      |                                ^~~~
Azer.cpp:36:26: error: reference to 'prev' is ambiguous
   36 |   else sn = pq.top().f - prev;
      |                          ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/vector:60,
                 from Azer.h:6,
                 from Azer.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Azer.cpp:13:32: note:                 'int prev'
   13 | int n, dc, c, st, sn, re, idx, prev;
      |                                ^~~~

Baijan.cpp: In function 'void dijkstra(int, int)':
Baijan.cpp:20:10: error: reference to 'prev' is ambiguous
   20 |   val += prev;
      |          ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/vector:60,
                 from Baijan.h:7,
                 from Baijan.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Baijan.cpp:13:32: note:                 'int prev'
   13 | int n, dc, c, st, sn, re, idx, prev;
      |                                ^~~~
Baijan.cpp:21:3: error: reference to 'prev' is ambiguous
   21 |   prev = val;
      |   ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/vector:60,
                 from Baijan.h:7,
                 from Baijan.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Baijan.cpp:13:32: note:                 'int prev'
   13 | int n, dc, c, st, sn, re, idx, prev;
      |                                ^~~~
Baijan.cpp:36:26: error: reference to 'prev' is ambiguous
   36 |   else sn = pq.top().f - prev;
      |                          ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/vector:60,
                 from Baijan.h:7,
                 from Baijan.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Baijan.cpp:13:32: note:                 'int prev'
   13 | int n, dc, c, st, sn, re, idx, prev;
      |                                ^~~~