这个似乎可以卡掉 dfs ?
查看原帖
这个似乎可以卡掉 dfs ?
654462
Silver_ash楼主2022/9/17 19:30
#include <cstdio>
#include <vector>
const int max_poi = 3000, max_link = 10000;
int cnt_poi = 0, cnt_link, cnt_val;
struct node{
    int u, v, w;
    node(){}
    node(int a, int b, int c){u = a, v = b, w = c;}
};
std::vector<node> edge;
int main(){
    while(true){
        if(cnt_link + 40 >= max_link) break;
        if(cnt_poi + 40 >= max_poi) break;
        edge.push_back(node(cnt_poi + 2, cnt_poi + 1, cnt_val - 1));
        edge.push_back(node(cnt_poi + 3, cnt_poi + 2, cnt_val - 1));
        edge.push_back(node(cnt_poi + 3, cnt_poi + 1, cnt_val - 1));
        
        edge.push_back(node(cnt_poi + 5, cnt_poi + 3, cnt_val - 1));
        edge.push_back(node(cnt_poi + 4, cnt_poi + 3, cnt_val - 1));
        edge.push_back(node(cnt_poi + 5, cnt_poi + 4, cnt_val - 1));
        
        cnt_poi += 4, cnt_link += 6, cnt_val -= 1;
    }
        edge.push_back(node(cnt_poi + 2, cnt_poi + 1, cnt_val - 1));
        edge.push_back(node(cnt_poi + 3, cnt_poi + 2, cnt_val - 1));
        edge.push_back(node(cnt_poi + 3, cnt_poi + 1, cnt_val - 1));
        edge.push_back(node(cnt_poi + 5, cnt_poi + 3, cnt_val - 1));
        edge.push_back(node(cnt_poi + 4, cnt_poi + 3, cnt_val - 1));
        edge.push_back(node(cnt_poi + 5, cnt_poi + 4, cnt_val - 1));
    cnt_link += 6;
        edge.push_back(node(cnt_poi + 4 + 2, cnt_poi     + 1, cnt_val - 3));
        edge.push_back(node(cnt_poi + 4 + 3, cnt_poi + 4 + 2, cnt_val - 3));
        edge.push_back(node(cnt_poi + 4 + 3, cnt_poi     + 1, cnt_val - 3));
        edge.push_back(node(cnt_poi + 4 + 5, cnt_poi + 4 + 3, cnt_val - 3));
        edge.push_back(node(cnt_poi + 4 + 4, cnt_poi + 4 + 3, cnt_val - 3));
        edge.push_back(node(cnt_poi + 4 + 5, cnt_poi + 4 + 4, cnt_val - 3));
    cnt_link += 6;    
        edge.push_back(node(cnt_poi + 8 + 2, cnt_poi     + 1, cnt_val - 2));
        edge.push_back(node(cnt_poi + 8 + 3, cnt_poi + 8 + 2, cnt_val - 2));
        edge.push_back(node(cnt_poi + 8 + 3, cnt_poi     + 1, cnt_val - 2));
        edge.push_back(node(cnt_poi + 8 + 5, cnt_poi + 8 + 3, cnt_val - 2));
        edge.push_back(node(cnt_poi + 8 + 4, cnt_poi + 8 + 3, cnt_val - 2));
        edge.push_back(node(cnt_poi + 8 + 5, cnt_poi + 8 + 4, cnt_val - 2));
    cnt_link += 6;    
    edge.push_back(node(1, cnt_poi + 0 + 5, 1e7));
    edge.push_back(node(1, cnt_poi + 4 + 5, 1e7));
    edge.push_back(node(1, cnt_poi + 8 + 5, 1e7));
    cnt_link += 3;
    cnt_poi += 15;
    printf("%d %d\n", cnt_poi, cnt_link);
    for(auto i : edge) printf("%d %d %d\n", i.u, i.v, i.w);

    return 0;
}
2022/9/17 19:30
加载中...