예제 #1
0
파일: test.cpp 프로젝트: ak795/acm
int main()
{
    VVI vv;
    VI v(3);
    v[0] = 1;
    v[1] = 5;
    v[2] = 6;

    vv.PB(v);
    v[0] = 2;
    v[1] = 7;
    v[2] = 8;

    vv.PB(v);
    REPSZ(i, vv) print(vv[i]);
    // sort(vv.begin(), vv.end(), cmpVector);
    REPSZ(i, vv) print(vv[i]);
    cout << "//////"<<endl;

    VI v2;
    v2.PB(2);
    v2.PB(1);
    v2.PB(3);
    sort(v2.begin(), v2.end(), mycmp);
    //    sort(v2.begin(), v2.end());
    print(v2);

    VS vs;
    vs.PB("12");
    vs.PB("9");
    vs.PB("312");

    sort(vs.begin(), vs.end(), sss);
    print(vs);
}
예제 #2
0
파일: p2.cpp 프로젝트: bolatov/contests
    int maxDifference(VS is, int dec) {
        VVI g;
        for (int i = 0; i < SZ(is); i++) {
            g.PB(VI());
            for (int j = 0; j < SZ(is[i]); j++) {
                if (is[i][j] == 'Y') {
                    g[i].PB(j);
                }
            }
        }
        if (findComps(g) > 1) {
            return -1;
        }

        int maxD = 0;
        for (int s = 0; s < SZ(g); s++) {
            queue<int> q;
            q.push(s);
            VB u(SZ(g));
            VI d(SZ(g));
            u[s] = true;
            while (!q.empty()) {
                int v = q.front();
                q.pop();
                for (int i = 0; i < SZ(g[v]); i++) {
                    int to = g[v][i];
                    if (!u[to]) {
                        u[to] = true;
                        q.push(to);
                        d[to] = d[v] + 1;
                    }
                }
            }
            for (int i = 0; i < SZ(d); i++) {
                maxD = max(maxD, d[i]);
            }
        }
        return maxD * dec;
    }