제출 #1362286

#제출 시각아이디문제언어결과실행 시간메모리
1362286Almonther자매 도시 (APIO20_swap)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
#include "swap.h"

using namespace std;

#define ll long long
const int maxn=1e5+5,sqr=447;
int n,m,f=0;
vector<array<int,3>>edges;
int par[maxn][sqr+5],sz[maxn][sqr+5],cnt[maxn][sqr+5];
bitset<sqr+5>good[maxn];
int dsu(int x,int sq){
    if(par[x][sq]==x) return x;
    return par[x][sq]=dsu(par[x][sq],sq);
}
void init(int N, int M,std::vector<int> U, std::vector<int> V, std::vector<int> W) {
    n=N,m=M;
    for(int i=0;i<m;i++) edges.push_back({W[i],V[i],U[i]});
    sort(edges.begin(),edges.end());
    for(int i=0;i<n;i++) par[i][0]=i,sz[i][0]=1,good[i][0]=cnt[i][0]=0;
    for(int i=1;(i-1)*sqr<m;i++){
        if(i) for(int j=0;j<n;j++) par[j][i]=par[j][i-1],sz[j][i]=sz[j][i-1],good[j][i]=good[j][i-1],cnt[j][i]=cnt[j][i-1];
        for(int j=(i-1)*sqr;j<i*sqr&&j<m;j++){
            auto[w,a,b]=edges[j];
            int a1=a,b1=b;
            a=dsu(a,i);
            b=dsu(b,i);
            if(a==b){
                good[a][i]=1;
                continue;
            }
            if(sz[a][i]<sz[b][i]) swap(a,b);
            cnt[a1][i]++;
            cnt[b1][i]++;
            if(cnt[a1][i]==3) good[a][i]=1;
            if(cnt[b1][i]==3) good[b][i]=1;
            sz[a][i]+=sz[b][i];
            par[b][i]=a;
            good[a][i]|=good[b][i];
        }
    }
}
int getMinimumFuelCapacity(int X, int Y) {
    if(dsu(X,m/sqr+1)!=dsu(Y,m/sqr+1)||good[dsu(X,m/sqr+1)][m/sqr+1]==0) return -1;
    int last=0;
    for(int i=1;(i-1)*sqr<m;i++){
        if(dsu(X,i)==dsu(Y,i)&&good[dsu(X,i)][i]==1){
            last=i-1;
            break;
        }
    }
    int ans=0;
    vector<array<int,5>>nodes;
    for(int j=last*sqr;;j++){
        auto[w,a,b]=edges[j];
        nodes.push_back({a,par[a][last],sz[a][last],good[a][last],cnt[a][last]});
        nodes.push_back({b,par[b][last],sz[b][last],good[b][last],cnt[b][last]});
        int a1=a,b1=b;
        a=dsu(a,last);
        b=dsu(b,last);
        if(a==b){
            good[a][last]=1;
            if(dsu(X,last)==dsu(Y,last)&&good[dsu(X,last)][last]==1){
                ans=w;
                break;
            }
            continue;
        }
        if(sz[a][last]<sz[b][last]) swap(a,b);
        cnt[a1][last]++;
        cnt[b1][last]++;
        if(cnt[a1][last]==3) good[a][last]=1;
        if(cnt[b1][last]==3) good[b][last]=1;
        sz[a][last]+=sz[b][last];
        par[b][last]=a;
        good[a][last]|=good[b][last];
        if(dsu(X,last)==dsu(Y,last)&&good[dsu(X,last)][last]==1){
            ans=w;
            break;
        }
    }
    reverse(nodes.begin(),nodes.end());
    for(auto [id,parr,szz,goo,cn]:nodes) par[id][last]=parr,sz[id][last]=szz,good[id][last]=goo,cnt[id][last]=cn;
    return ans;
}

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

swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:39:23: error: no match for 'operator|=' (operand types are 'std::bitset<452>::reference' and 'std::bitset<452>::reference')
   39 |             good[a][i]|=good[b][i];
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:176,
                 from swap.cpp:1:
/usr/include/c++/13/future:179:18: note: candidate: 'std::launch& std::operator|=(launch&, launch)'
  179 |   inline launch& operator|=(launch& __x, launch __y) noexcept
      |                  ^~~~~~~~
/usr/include/c++/13/future:179:37: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::launch&'
  179 |   inline launch& operator|=(launch& __x, launch __y) noexcept
      |                             ~~~~~~~~^~~
In file included from /usr/include/c++/13/format:39,
                 from /usr/include/c++/13/bits/chrono_io.h:39,
                 from /usr/include/c++/13/chrono:3370,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:172:
/usr/include/c++/13/charconv:657:3: note: candidate: 'constexpr std::chars_format& std::operator|=(chars_format&, chars_format)'
  657 |   operator|=(chars_format& __lhs, chars_format __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/13/charconv:657:28: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::chars_format&'
  657 |   operator|=(chars_format& __lhs, chars_format __rhs) noexcept
      |              ~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/13/streambuf:43,
                 from /usr/include/c++/13/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/13/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:54:
/usr/include/c++/13/bits/ios_base.h:182:3: note: candidate: 'const std::_Ios_Iostate& std::operator|=(_Ios_Iostate&, _Ios_Iostate)'
  182 |   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:182:28: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::_Ios_Iostate&'
  182 |   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |              ~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/ios_base.h:142:3: note: candidate: 'const std::_Ios_Openmode& std::operator|=(_Ios_Openmode&, _Ios_Openmode)'
  142 |   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:142:29: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::_Ios_Openmode&'
  142 |   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/ios_base.h:99:3: note: candidate: 'const std::_Ios_Fmtflags& std::operator|=(_Ios_Fmtflags&, _Ios_Fmtflags)'
   99 |   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:99:29: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::_Ios_Fmtflags&'
   99 |   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |              ~~~~~~~~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:41:
/usr/include/c++/13/cstddef:167:3: note: candidate: 'constexpr std::byte& std::operator|=(byte&, byte)'
  167 |   operator|=(byte& __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/13/cstddef:167:20: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::byte&'
  167 |   operator|=(byte& __l, byte __r) noexcept
      |              ~~~~~~^~~
swap.cpp: In function 'int getMinimumFuelCapacity(int, int)':
swap.cpp:76:22: error: no match for 'operator|=' (operand types are 'std::bitset<452>::reference' and 'std::bitset<452>::reference')
   76 |         good[a][last]|=good[b][last];
/usr/include/c++/13/future:179:18: note: candidate: 'std::launch& std::operator|=(launch&, launch)'
  179 |   inline launch& operator|=(launch& __x, launch __y) noexcept
      |                  ^~~~~~~~
/usr/include/c++/13/future:179:37: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::launch&'
  179 |   inline launch& operator|=(launch& __x, launch __y) noexcept
      |                             ~~~~~~~~^~~
/usr/include/c++/13/charconv:657:3: note: candidate: 'constexpr std::chars_format& std::operator|=(chars_format&, chars_format)'
  657 |   operator|=(chars_format& __lhs, chars_format __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/13/charconv:657:28: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::chars_format&'
  657 |   operator|=(chars_format& __lhs, chars_format __rhs) noexcept
      |              ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/13/bits/ios_base.h:182:3: note: candidate: 'const std::_Ios_Iostate& std::operator|=(_Ios_Iostate&, _Ios_Iostate)'
  182 |   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:182:28: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::_Ios_Iostate&'
  182 |   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |              ~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/ios_base.h:142:3: note: candidate: 'const std::_Ios_Openmode& std::operator|=(_Ios_Openmode&, _Ios_Openmode)'
  142 |   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:142:29: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::_Ios_Openmode&'
  142 |   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/ios_base.h:99:3: note: candidate: 'const std::_Ios_Fmtflags& std::operator|=(_Ios_Fmtflags&, _Ios_Fmtflags)'
   99 |   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |   ^~~~~~~~
/usr/include/c++/13/bits/ios_base.h:99:29: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::_Ios_Fmtflags&'
   99 |   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/cstddef:167:3: note: candidate: 'constexpr std::byte& std::operator|=(byte&, byte)'
  167 |   operator|=(byte& __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/13/cstddef:167:20: note:   no known conversion for argument 1 from 'std::bitset<452>::reference' to 'std::byte&'
  167 |   operator|=(byte& __l, byte __r) noexcept
      |              ~~~~~~^~~