QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#293192#7860. Graph of Maximum Degree 3ucup-team139Compile Error//C++231.9kb2023-12-28 23:08:522023-12-28 23:08:52

Judging History

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

  • [2023-12-28 23:08:52]
  • 评测
  • [2023-12-28 23:08:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

void solve(int t){
    int n,m;
    cin>>n>>m;
    
    vector red(n,vector<int>()),blue(n,vector<int>());
    
    map<pair<int,int>,int> cont;
    for(int i=0;i<m;i++){
        int u,v,c;
        cin>>u>>v>>c;
        u--;
        v--;
        
        cont[{min(u,v),max(u,v)}]++;
        (c == 0 ? red : blue)[u].push_back(v);
        (c == 0 ? red : blue)[v].push_back(u);
    }
    
    vector vis(n,false);
    int ans = n;
    for(auto [i,j] : cont)if(j==2)ans++;
    for(int i=0;i<n;i++){
        if(red[i].size()==3){
            vis[i]=true;
        }
    }
    
    vector<int> v;
    auto dfs = [&](auto &dfs,int nodo){
        if(vis[nodo])return;
        v.push_back(nodo);
        vis[nodo]=true;
        
        for(auto i : red[nodo])dfs(dfs,i);
    };
    
    vector ok(n,false);
    for(int i=0;i<n;i++){
        if(vis[i]==false){
            v.clear();
            dfs(dfs,i);
            
            for(int i=0;i<(int)v.size();i++){
                for(int j=i+2;j<min((int)v.size(),i+4);j++){
                    int cc=0;
                    for(int k=i;k<=j;k++){
                        ok[v[k]]=true;
                    }
                    
                    for(int k=i;k<=j;k++){
                        for(auto l : blue[v[k]]){
                            if(ok[l])cc++;
                        }
                    }
                    
                    for(int k=i;k<=j;k++){
                        ok[v[k]]=false;
                    }
                    //cout<<i<<" "<<j<<" "<<cc<<" ecco\n";
                    assert(cc%2==0);
                    if(cc/2==j-i)ans++;
                }
            }
        }
    }
    assert(ans<mod);
    cout<<ans<<"\n";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)solve(i);
    
    return 0;
}

详细

In file included from /usr/include/c++/11/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:33,
                 from answer.code:1:
answer.code: In function ‘void solve(int)’:
answer.code:69:16: error: ‘mod’ was not declared in this scope; did you mean ‘modf’?
   69 |     assert(ans<mod);
      |                ^~~