제출 #896799

#제출 시각아이디문제언어결과실행 시간메모리
896799NotLinux사이버랜드 (APIO23_cyberland)C++17
컴파일 에러
0 ms0 KiB
#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
#define ll __int128
#define VAR pair < pair < ll , ll > , pair < int , int > >
const int MAXK = 31;
inline ll gcd(ll a , ll b){
    a = abs(a) , b = abs(b);
    while(a and b){
        if(a > b)swap(a,b);
        else if(a == 0)return b;
        else {
            b %= a;
            swap(a,b);
        }
    }
    return b;
}
inline pair < ll , ll > subt(pair < ll , ll > a , pair < ll , ll > b){
    // cout << "gh1" << endl;
    ll pay = a.first * b.second - a.second * b.first;
    ll payda = a.second * b.second;
    ll gc = gcd(pay , payda);
    if(pay < 0 and payda < 0)gc *= -1;
    // cout << "gh2 : " << pay << " " << payda << " " << gc << endl;
    // cout << pay/gc << endl;
    // cout << payda/gc << endl;
    // cout << "finished" << endl;
    return {pay/gc , payda/gc};
}
struct cmp{
    bool operator()(VAR a , VAR b){
        return a.first.first * b.first.second < a.first.second * b.first.first;
    }
};
double solve(int n, int m, int k, int h, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
    // cout << "starting " << endl;
    bitset < 31 > vis[n];
    fill(vis , vis + n , 0);
 
    vector < pair < int , int > > graph[n];
    for(int i = 0;i<m;i++){
        graph[x[i]].push_back({y[i] , c[i]});
        graph[y[i]].push_back({x[i] , c[i]});
    }
 
    priority_queue < VAR , vector < VAR > , cmp > pq;//dist , node , how much k used
    pq.push({{0,1},{0,0}});
 
    function < void (int) > dfs = [&](int cur){
        if(vis[cur] == 1 or cur == h)return;
        vis[cur] = 1;
        if(arr[cur] == 0){
            pq.push({{0,1},{cur,0}});
            // cout << "pushed : " << cur << endl;
        }
        for(auto itr : graph[cur]){
            dfs(itr.first);
        }
    };
    // cout << "flag0 " << endl;
    dfs(0);
    fill(vis , vis + n , 0);
 
    double ans = 1;
    // cout << "flag1 " << endl;
    while(pq.size()){
        VAR tmp = pq.top();
        pq.pop();
        if(vis[tmp.second.first][tmp.second.second])continue;
        vis[tmp.second.first][tmp.second.second] = 1;
        // cout << "pq : " << tmp.first.first << " / " << tmp.first.second << " , " << tmp.second.first << " " << tmp.second.second << endl;
        double reelval = (double)tmp.first.first / (double)tmp.first.second;
        if(tmp.second.first == h){
            // cout << "flag1.1" << endl;
            if(ans == 1 or ans < reelval){
                ans = reelval;
            }
            // cout << "flag1.2" << endl; 
        }
        else{
            // cout << "flag2.1" << endl;
            for(auto itr : graph[tmp.second.first]){
                if(arr[tmp.second.first] == 2 and tmp.second.second < k){
                    pq.push({subt({tmp.first.first , tmp.first.second * 2ll},{itr.second , 1ll}) , {itr.first , tmp.second.second+1}});
                }
                pq.push({subt(tmp.first , {itr.second , 1ll}) , {itr.first , tmp.second.second}});
            }
            // cout << "flag2.2" << endl;
        }
    }
    // cout << "flag3 " << endl;
    return -ans;
}

컴파일 시 표준 에러 (stderr) 메시지

cyberland.cpp: In function '__int128 gcd(__int128, __int128)':
cyberland.cpp:8:14: error: call of overloaded 'abs(__int128&)' is ambiguous
    8 |     a = abs(a) , b = abs(b);
      |              ^
In file included from /usr/include/c++/10/bits/std_abs.h:38,
                 from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from cyberland.cpp:2:
/usr/include/stdlib.h:840:12: note: candidate: 'int abs(int)'
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from cyberland.cpp:2:
/usr/include/c++/10/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
cyberland.cpp:8:27: error: call of overloaded 'abs(__int128&)' is ambiguous
    8 |     a = abs(a) , b = abs(b);
      |                           ^
In file included from /usr/include/c++/10/bits/std_abs.h:38,
                 from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from cyberland.cpp:2:
/usr/include/stdlib.h:840:12: note: candidate: 'int abs(int)'
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from cyberland.cpp:2:
/usr/include/c++/10/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/10/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~