QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#687002#4938. Writing TasksSanguineChameleonCompile Error//C++202.5kb2024-10-29 16:42:282024-10-29 16:42:28

Judging History

你现在查看的是最新测评结果

  • [2024-10-29 16:42:28]
  • 评测
  • [2024-10-29 16:42:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define mp make_pair
#define eb emplace_back
#define pb push_back
typedef pair<int,int> pii;




const int mxn=1e6+5;

vector<int> adjl[mxn];
bool vis[mxn];
bool col[mxn];
int b,w;
int maxDeg;

void dfs(int nd,int cc=0){
    maxDeg = max(maxDeg, (int)nd.size());
    col[nd]=cc;
    if(col[nd])b++;
    else w++;
    vis[nd]=1;
    for(int x:adjl[nd]){
        if(vis[x]){
            //assert(col[x]!=col[nd]);
            continue;
        }
        dfs(x,1-cc);
    }
}


vector<pii> tt[mxn],cc[mxn];//each topic/contest, authors they're connected to
vector<pair<int,pii> > trips;
vector<int> nodes[mxn];
int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(0);
    int a,c,t;
    cin>>a>>c>>t;
    int cur=1;
    for(int i=1;i<=a;i++){
        int l;cin>>l;
        for(int j=0;j<l;j++){
            int a;cin>>a;
            //author i -> contest a
            cc[a].eb(i,cur++);
        }
    }

    for(int i=1;i<=a;i++){
        int l;cin>>l;
        for(int j=0;j<l;j++){
            int a;cin>>a;
            //author i -> topic a
            tt[a].eb(i,cur++);
        }
    }

    int xx=1;
    for(int i=1;i<=c;i++){
        int l;cin>>l;
        for(int j=0;j<l;j++){
            int a;cin>>a;
            //cur: contest i -> topic a
            for(pii x:cc[i]){
                for(pii y:tt[a]){
                    if(x.f==y.f){
                        //triangle: author, contest, topic
                        nodes[x.s].pb(trips.size());
                        nodes[y.s].pb(trips.size());
                        nodes[cur].pb(trips.size());
                        trips.eb(x.f,mp(i,a));
                    }
                }
            }
            cur++;
        }
    }

    // for(auto x:trips){
    //     cout<<x.f<<' '<<x.s.f<<' '<<x.s.s<<'\n';
    // }

    for(int i=1;i<cur;i++){
        assert(nodes[i].size()<=2);
        if(nodes[i].size()==2){
            int u=nodes[i][0];
            int v=nodes[i][1];
            adjl[u].pb(v);
            adjl[v].pb(u);
            // cout<<u<<' '<<v<<'\n';
        }
    }

    int ans=0;
    for(int i=0;i<trips.size();i++){
        if(vis[i])continue;
        b=w=0;
        dfs(i);
        if(b<w)swap(b,w);
        ans+=b;
        if (maxDeg >= 3) {
            assert(b + w <= 8);
        }
    }
    cout<<ans;
}

Details

answer.code: In function ‘void dfs(long long int, long long int)’:
answer.code:23:34: error: request for member ‘size’ in ‘nd’, which is of non-class type ‘long long int’
   23 |     maxDeg = max(maxDeg, (int)nd.size());
      |                                  ^~~~