답안 #728476

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
728476 2023-04-22T13:21:09 Z Charizard2021 Flight to the Ford (BOI22_communication) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include<communication.h>
using namespace std;
using ll = long long;
mt19937 rngQ(23478123);
 
ll K = rngQ();
 
void encode(int N, int X) {
    vector < ll > v(250, -1);
    vector < ll > b1, b2;
    mt19937 rng(K);
    for(ll i = 0; i < 250; i++){
        if(rng()%3 == 1 && (!i || v[i - 1] == -1) ){
            v[i] = rng()%2;
        }else{
            if(rng()%2) b1.push_back(i);
            else b2.push_back(i);
        }
    }
    for(auto u : b1) v[u] = (1 << 0) & X;
    for(auto u : b2) v[u] = (X >> 1) & 1;
    for(auto u : v) send(u);
    return;
}
 
std::pair<int, int> decode(int N) {
    vector < ll > v(250, -1);
    mt19937 rng2(K);
    vector < ll > rem, b1, b2;
    for(ll i = 0; i < 250; i++){
        if(rng2()%3 == 1 && (!i || v[i - 1] == -1) ){
            v[i] = rng2()%2;
        }else{
            if(rng2()%2) b1.push_back(i);
            else b2.push_back(i);
        }
    }
    vector < ll > g(250);
    for(ll i = 0; i < 250; i++) g[i] = receive();
    ll sure = 0, ok1 = 0, ok2 = 0, c1 = 0, c2 = 0;
    for(auto u : b1){
        if(u && v[u - 1] != -1 && v[u - 1] != g[u - 1]) sure |= g[u], ok1 = 1;
        if(u + 1 < 250 && v[u + 1] != -1 && v[u + 1] != g[u + 1]) sure |= g[u], ok1 = 1;
        c1 += (g[u] == 0 ? -1 : 1);
    }
    for(auto u : b2){
        if(u && v[u - 1] != -1 && v[u - 1] != g[u - 1]) sure |= (g[u] << 1), ok2 = 1;
        if(u + 1 < 250 && v[u + 1] != -1 && v[u + 1] != g[u + 1]) sure |= (g[u] << 1), ok2 = 1;
        c2 += (g[u] == 0 ? -1 : 1);
    }
    ll a1 = sure, a2 = sure;
    if(!ok1 && !ok2){
        if(max(c1, c2) == c1){
            if(c1 >= 0) a1 |= 1, a2 |= 1;
            if(c2 >= 0) a2 |= 2; 
        }else{
            if(c2 >= 0) a1 |= 2, a2 |= 2;
            if(c1 >= 0) a1 |= 1;
        }
    }else{
        if(!ok1 && c1 >= 0) a1 |= 1;
        if(!ok2 && c2 >= 0) a1 |= 2;
    }
    a1 = min(a1, N);
    a1 = max(1 , a1);
    a2 = max(1 , a2);
    a2 = min(a2, N);
    assert(1 <= min(a1, a2) && max(a1, a2) <= N);
    while(a1 == a2){
        a1++;
        if(a1 == N+1) a1 = 1;
    }
    return {a1, a2};
}

Compilation message

communication.cpp: In function 'std::pair<int, int> decode(int)':
communication.cpp:65:19: error: no matching function for call to 'min(ll&, int&)'
   65 |     a1 = min(a1, N);
      |                   ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
communication.cpp:65:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   65 |     a1 = min(a1, N);
      |                   ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
communication.cpp:65:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   65 |     a1 = min(a1, N);
      |                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
communication.cpp:65:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   65 |     a1 = min(a1, N);
      |                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
communication.cpp:65:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   65 |     a1 = min(a1, N);
      |                   ^
communication.cpp:66:20: error: no matching function for call to 'max(int, ll&)'
   66 |     a1 = max(1 , a1);
      |                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
communication.cpp:66:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   66 |     a1 = max(1 , a1);
      |                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
communication.cpp:66:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   66 |     a1 = max(1 , a1);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
communication.cpp:66:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   66 |     a1 = max(1 , a1);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
communication.cpp:66:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   66 |     a1 = max(1 , a1);
      |                    ^
communication.cpp:67:20: error: no matching function for call to 'max(int, ll&)'
   67 |     a2 = max(1 , a2);
      |                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
communication.cpp:67:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   67 |     a2 = max(1 , a2);
      |                    ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
communication.cpp:67:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   67 |     a2 = max(1 , a2);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
communication.cpp:67:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   67 |     a2 = max(1 , a2);
      |                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
communication.cpp:67:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   67 |     a2 = max(1 , a2);
      |                    ^
communication.cpp:68:19: error: no matching function for call to 'min(ll&, int&)'
   68 |     a2 = min(a2, N);
      |                   ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
communication.cpp:68:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   68 |     a2 = min(a2, N);
      |                   ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
communication.cpp:68:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   68 |     a2 = min(a2, N);
      |                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
communication.cpp:68:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   68 |     a2 = min(a2, N);
      |                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from communication.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
communication.cpp:68:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   68 |     a2 = min(a2, N);
      |                   ^