惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
小众软件
小众软件
Last Week in AI
Last Week in AI
月光博客
月光博客
博客园 - 聂微东
Recent Announcements
Recent Announcements
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky
云风的 BLOG
云风的 BLOG
量子位
N
Netflix TechBlog - Medium
Hugging Face - Blog
Hugging Face - Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
博客园 - 司徒正美
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
宝玉的分享
宝玉的分享

某岛

AtCoder Beginner Contest 409 Luogu P5325. 【模板】Min_25 筛 UOJ #188. 【UR #13】Sanrd AtCoder Beginner Contest 371 AtCoder Beginner Contest 369 RPGMaker 2k3 百科 OneShot 的考古 2024“开创拓芯”游戏创享节的相关记录 CJ 回来后的戒断反应 Luogu P10221. [省选联考 2024] 重塑时光 Luogu P5308 [COCI2018-2019#4] Akvizna wqs 二分 歌唱王国 Lean 相关 BZOJ 3153. Sone1 The 2023 ICPC World Finals Luxor 新巴别塔 Sora 的想象与思考 Facebook Hacker Cup 2023 Round 1 AtCoder Beginner Contest 322 LLaMA 2 相关 HuggingFace AI Game Jam ACL 2023 Trans 相关… Luogu P2053. [SCOI2007] 修车 Luogu P1973. [NOI2011] NOI 嘉年华 Luogu P1933. [NOI2010] 旅行路线 Luogu P1954. [NOI2010] 航空管制 Luogu P2048. [NOI2010] 超级钢琴 Luogu P2046. [NOI2010] 海拔
Codechef JUNE15. Chefbook
2022-07-07 · via 某岛

我靠这个还要构造解。。。。
WA ing


const int N = 1000, M = N*N;
VI in[N], out[N];

struct Simplex {
    const static int N = int(1e4) + 9, M = int(1e4) + 9;
    DB a[N][M]; int b[N], c[M], X[M];
    int n, m;

    void pivot(int in, int out) {
        REP(i, m+1) if(i!=in) a[out][i] /= -a[out][in]; //重置out约束
        a[out][in] = 1/a[out][in];

        REP(i, n+1) if (i!=out && sgn(a[i][in])) { //重新计算其他约束
            DB t = a[i][in]; a[i][in] = 0;
            REP(j, m+1) a[i][j] += t*a[out][j];
        }
        swap(c[in], b[out]);
    }

    void run() {

        REP_1(i, n) b[i] = -i;
        REP_1(i, m) c[i] = i;

        while (true) {
            int in=0, out=0; DB Min=OO;
            REP_1(i, m) if(sgn(a[0][i])>0) {
                in=i;
                break;
            }
            if(!in)return;
            REP_1(i, n) if(sgn(a[i][in])<0&&a[i][0]/-a[i][in]<Min) {
                Min=a[i][0]/-a[i][in];
                out=i;
            }
            if(!out) return; //throw ; //unbounded
            pivot(in, out);
        }
    }

    struct Edge {
        int x,y,w,s,t;
        void in() {
            RD(x,y,w,s,t);
            --x; --y;
        }
    } E[::M];

    void gao() {
// z c
// b A

        RD(n, m);

        REP(i, n) {
            in[i].clear();
            out[i].clear();
        }

        REP(i, m){
            E[i].in();
            int x = E[i].x, y = E[i].y, w = E[i].w, s = E[i].s, t = E[i].t;
            in[x].PB(y); out[y].PB(x); a[0][0] += w;
            DB (&r0)[M] = a[i+1]; r0[0] = t - w; r0[x+1] -= 1; r0[n+y+1] += 1;
            DB (&r1)[M] = a[m+i+1]; r1[0] = w - s; r1[x+1] += 1; r1[n+y+1] -= 1;
        }

        REP(i, n) a[0][i+1] += SZ(out[i]);
        REP(i, n) a[0][n+i+1] -= SZ(in[i]);

        n *= 2; m *= 2; swap(n, m);

        /*
        REP(i, n+1) {
            REP(j, m+1) cout << a[i][j] << " ";
            cout << endl;
        }

        REP_1(i, n) cout << b[i] << " "; cout << endl;
        REP_1(i, m) cout << c[i] << " "; cout << endl;
        REP_1(i, m) cout << X[i] << " "; cout << endl;
        */

        run();

        /*
        cout << "-----------" << endl;

        REP(i, n+1) {
            REP(j, m+1) cout << a[i][j] << " ";
            cout << endl;
        }
        cout << "-----------" << endl;
        */



        /*REP_1(i, m/2) {
            cout << a[0][i] << " "<< a[0][m/2+i] << endl;
        }*/


        REP_1(i, m) X[i] = 0;
        REP_1(i, n) if (b[i] > 0) X[b[i]] = a[i][0];

        /*
        REP_1(i, n) cout << b[i] << " "; cout << endl;
        REP_1(i, m) cout << c[i] << " "; cout << endl;
        REP_1(i, m) cout << X[i] << " "; cout << endl;
        */

        REP(i, n/2) {
            int x = E[i].x, y = E[i].y, w = E[i].w, s = E[i].s, t = E[i].t;
            w += X[x+1]; w -= X[m/2+y+1];
            if (w < s || t < w) {
                puts("Unlike");
                REP(i, n+1) {
                    REP(j, m+1) a[i][j] = 0;
                }
                return;
            }
        }

        OT((LL)a[0][0]);
        REP_1(i, m/2) {
            cout << (LL)X[i] << " "<< (LL)X[m/2+i] << endl;
        }


        REP(i, n+1) {
            REP(j, m+1) a[i][j] = 0;
        }
    }
} fst;

int main() {

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    Rush fst.gao();
}

Posted by xiaodao
Category: 日常