답안 #921857

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921857 2024-02-04T12:02:02 Z browntoad Escape Route (JOI21_escape_route) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "escape_route.h"
#pragma GCC optimize ("Ofast", "unroll-loops")
using namespace std;
#define ll long long
// #define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define RREP1(i,n) for (int i=(n); i>=1; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<ll, ll>
#define pip pair<int, pii>
#define ppi pair<ll, ll>
#define pdd pair<double ,double>
#define pcc pair<char, char>
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS()
#else
#define bug(...)
#define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#endif
 
const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 998244353;
const ll maxn=505;
const ll maxm=15;
const double PI=acos(-1);
 
ll pw(ll x, ll p, ll m=mod){
    if (p < 0) return 0;
    ll ret=1;
    while (p>0){
        if (p&1){
            ret*=x;
            ret%=m;
        }
        x*=x;
        x%=m;
        p>>=1;
    }
    return ret;
}
 
ll inv(ll a, ll m=mod){
    return pw(a,m-2,m);
}
int n, m, SS, q;
struct edge{
    int v;
    int l, c; // length, check
};
vector<edge> g[maxn];
 
pii D(ppi U, edge E){
    if (U.f.s + E.l > E.c){
        U.f.f += SS-U.f.s;
        U.f.s = 0;
 
        U.f.f += E.l;
        U.f.s = E.l;
    }
    else {
        U.f.f += E.l;
        U.f.s += E.l;
    }
    return U.f;
}
std::vector<long long> calculate_necessary_time(int N, int M, long long S, int Q, std::vector<int> A, std::vector<int> B,std::vector<long long> L, std::vector<long long> C, std::vector<int> U,std::vector<int> V,std::vector<long long> T){
  	n = N; m = M; SS = S; q = Q;
    REP(i, m){
        ll u, v, a, b; 
      	u = A[i]; v = B[i]; a = L[i]; b = C[i];
      
        g[u].pb({v, a, b});
        g[v].pb({u, a, b});
    }
  	vector<ll> ret;
    for (int z = 0; z < Q; z++){
        ll a, b, t; a = U[z]; b = V[z]; t = T[z];
        priority_queue<ppi, vector<ppi>, greater<ppi> > pq;
        pq.push({{0ll, t}, a}); // mod and node
 
        vector<bool> occ(n+1);
        vector<pii> dis(n+1);
        pii ou = {inf, inf};
        fill(ALL(dis), ou);
        dis[a] = {0ll, t};
        pii tmp;
        while(SZ(pq)){
            ppi tp = pq.top(); pq.pop();
            if (occ[tp.s]) continue;
            occ[tp.s] = 1;
            for (auto y:g[tp.s]){
                if (!occ[y.v]){
                    tmp = D(tp, y);
                    if (tmp < dis[y.v]){
                        dis[y.v] = tmp;
                        pq.push({dis[y.v], y.v});
                    }
                }
            }
        }
      	ret.pb(dis[b].f);
    }
  	return ret;
}

Compilation message

escape_route.cpp: In function 'std::pair<long long int, long long int> D(std::pair<long long int, long long int>, edge)':
escape_route.cpp:13:11: error: request for member 'second' in 'U.std::pair<long long int, long long int>::first', which is of non-class type 'long long int'
   13 | #define s second
      |           ^~~~~~
escape_route.cpp:66:13: note: in expansion of macro 's'
   66 |     if (U.f.s + E.l > E.c){
      |             ^
escape_route.cpp:12:11: error: request for member 'first' in 'U.std::pair<long long int, long long int>::first', which is of non-class type 'long long int'
   12 | #define f first
      |           ^~~~~
escape_route.cpp:67:13: note: in expansion of macro 'f'
   67 |         U.f.f += SS-U.f.s;
      |             ^
escape_route.cpp:13:11: error: request for member 'second' in 'U.std::pair<long long int, long long int>::first', which is of non-class type 'long long int'
   13 | #define s second
      |           ^~~~~~
escape_route.cpp:67:25: note: in expansion of macro 's'
   67 |         U.f.f += SS-U.f.s;
      |                         ^
escape_route.cpp:13:11: error: request for member 'second' in 'U.std::pair<long long int, long long int>::first', which is of non-class type 'long long int'
   13 | #define s second
      |           ^~~~~~
escape_route.cpp:68:13: note: in expansion of macro 's'
   68 |         U.f.s = 0;
      |             ^
escape_route.cpp:12:11: error: request for member 'first' in 'U.std::pair<long long int, long long int>::first', which is of non-class type 'long long int'
   12 | #define f first
      |           ^~~~~
escape_route.cpp:70:13: note: in expansion of macro 'f'
   70 |         U.f.f += E.l;
      |             ^
escape_route.cpp:13:11: error: request for member 'second' in 'U.std::pair<long long int, long long int>::first', which is of non-class type 'long long int'
   13 | #define s second
      |           ^~~~~~
escape_route.cpp:71:13: note: in expansion of macro 's'
   71 |         U.f.s = E.l;
      |             ^
escape_route.cpp:12:11: error: request for member 'first' in 'U.std::pair<long long int, long long int>::first', which is of non-class type 'long long int'
   12 | #define f first
      |           ^~~~~
escape_route.cpp:74:13: note: in expansion of macro 'f'
   74 |         U.f.f += E.l;
      |             ^
escape_route.cpp:13:11: error: request for member 'second' in 'U.std::pair<long long int, long long int>::first', which is of non-class type 'long long int'
   13 | #define s second
      |           ^~~~~~
escape_route.cpp:75:13: note: in expansion of macro 's'
   75 |         U.f.s += E.l;
      |             ^
escape_route.cpp:12:11: error: could not convert 'U.std::pair<long long int, long long int>::first' from 'long long int' to 'std::pair<long long int, long long int>'
   12 | #define f first
      |           ^
      |           |
      |           long long int
escape_route.cpp:77:14: note: in expansion of macro 'f'
   77 |     return U.f;
      |              ^
escape_route.cpp: In function 'std::vector<long long int> calculate_necessary_time(int, int, long long int, int, std::vector<int>, std::vector<int>, std::vector<long long int>, std::vector<long long int>, std::vector<int>, std::vector<int>, std::vector<long long int>)':
escape_route.cpp:85:18: warning: narrowing conversion of 'v' from 'long long int' to 'int' [-Wnarrowing]
   85 |         g[u].pb({v, a, b});
      |                  ^
escape_route.cpp:85:21: warning: narrowing conversion of 'a' from 'long long int' to 'int' [-Wnarrowing]
   85 |         g[u].pb({v, a, b});
      |                     ^
escape_route.cpp:85:24: warning: narrowing conversion of 'b' from 'long long int' to 'int' [-Wnarrowing]
   85 |         g[u].pb({v, a, b});
      |                        ^
escape_route.cpp:86:18: warning: narrowing conversion of 'u' from 'long long int' to 'int' [-Wnarrowing]
   86 |         g[v].pb({u, a, b});
      |                  ^
escape_route.cpp:86:21: warning: narrowing conversion of 'a' from 'long long int' to 'int' [-Wnarrowing]
   86 |         g[v].pb({u, a, b});
      |                     ^
escape_route.cpp:86:24: warning: narrowing conversion of 'b' from 'long long int' to 'int' [-Wnarrowing]
   86 |         g[v].pb({u, a, b});
      |                        ^
escape_route.cpp:92:30: error: no matching function for call to 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >::push(<brace-enclosed initializer list>)'
   92 |         pq.push({{0ll, t}, a}); // mod and node
      |                              ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from escape_route.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::greater<std::pair<long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, long long int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::greater<std::pair<long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, long long int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
escape_route.cpp:109:48: error: no matching function for call to 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >::push(<brace-enclosed initializer list>)'
  109 |                         pq.push({dis[y.v], y.v});
      |                                                ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from escape_route.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::greater<std::pair<long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, long long int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::greater<std::pair<long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, long long int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~