Submission #1057857

# Submission time Handle Problem Language Result Execution time Memory
1057857 2024-08-14T06:52:08 Z d(#11114) Infiltration (CCO24_day2problem1) C++17
Compilation error
0 ms 0 KB
#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

int N = 100;
int qu[100 + 5];
int T = 305;
bool mat[105][105];

struct BFSMetadata {
    int root;
    int mxdep;
    vector<int> dep;
    vector<int> par;

    BFSMetadata(int root, const vector<vector<int>>& graph) 
     : root(root), mxdep(0), dep(vector<int>(N)), par(vector<int>(N, -1)) {
        int bfsl = 0, bfsr = 0;
        qu[0] = root;
        while (bfsl <= bfsr) {
            int n = qu[bfsl++];
            mxdep = max(mxdep, dep[n]);
            for (int e : graph[n]) {
                if (e != par[n]) {
                    dep[e] = dep[n] + 1;
                    par[e] = n;
                    qu[++bfsr] = e;
                }
            }
        }
    }
};

vector<vector<int>> getInput() {
    N = inf.readInt();
    vector<vector<int>> graph(N);    
    for (int k = 1; k < N; k++) {
        int a = inf.readInt();
        int b = inf.readInt();
        mat[a][b] = mat[b][a] = 1;
        graph[a].push_back(b);  
        graph[b].push_back(a);
    }
    return graph;
}

int main(int argc, char* argv[]) {
    registerTestlibCmd(argc, argv);
    auto graph = getInput();

    string extra;
    string line = ouf.readLine();
    stringstream ss(line);
    if (!(ss >> T)) {
        ouf.quitf(_pe, "Invalid T");
    }
    if (T > 1440 || T < 0) {
        ouf.quitf(_wa, "T is not in [1, 1440]");
    }
    if (ss >> extra) {
        ouf.quitf(_pe, "Extra tokens on line");
    }                
    vector<vector<vector<int>>> strat = vector<vector<vector<int>>>(2, vector<vector<int>>(N, vector<int>(T + 1)));
    for (int x = 1; x >= 0; x--) {
        for (int n = 0; n < N; n++) {
            line = ouf.readLine();
            ss.clear();
            ss.str(line);            
            strat[x][n][0] = n;
            for (int t = 1; t <= T; t++) {
                if (!(ss >> strat[x][n][t])) {
                    ouf.quitf(_pe, "Invalid table value");
                }
                if (strat[x][n][t] < 0 || strat[x][n][t] >= N) {
                    ouf.quitf(_wa, "Not a valid node");
                }
                if (t % 2 == x && strat[x][n][t - 1] != strat[x][n][t] && !mat[strat[x][n][t - 1]][strat[x][n][t]]) {
                    ouf.quitf(_wa, "Node sequence is invalid");
                }
                if (t % 2 != x && strat[x][n][t - 1] != strat[x][n][t]) {
                    ouf.quitf(_wa, "Cannot move");
                }
            }
            if (ss >> extra) {
                ouf.quitf(_pe, "Extra tokens on line");
            }            
        }
    }
    ouf.readEof();
    BFSMetadata bst = BFSMetadata(0, graph);
    vector<BFSMetadata> metadata = {bst};
    for (int root = 1; root < N; root++) {
        BFSMetadata tmp = BFSMetadata(root, graph);
        metadata.push_back(tmp);
        if (bst.mxdep > tmp.mxdep) {
            swap(bst, tmp);
        }
    }
    double score = 0.0;
    for (int o = 0; o < N; o++) {
        for (int e = 0; e < N; e++) {
            if (o != e) {
                bool done = 0;
                for (int t = 0; t < T && !done; t++) {
                    if (strat[1][o][t] == strat[0][e][t]) {
                        score = max(score, 1.0 * t / metadata[o].dep[e]);
                        done = 1;
                    }
                }
                if (!done) {
                    ouf.quitf(_wa, "For some pair of nodes Ondrej and Edward do not meet each other");
                }
            }
        }
    }
  
  double max_score = 0;
  
            if (200 < score and score <= 1440)
                max_score = 3;
            else if (100 < score and score <= 200)
                max_score = 6;
            else if (50 < score and score <= 100)
                max_score = 8;
            else if (40 < score and score <= 50)
                max_score = 10;
            else if (30 < score and score <= 40)
                max_score = 12;
            else if (25 < score and score <= 30)
                max_score = 15;
            else if (20 < score and score <= 25)
                max_score = 17;
            else if (19 < score and score <= 20)
                max_score = 18;
            else if (18 < score and score <= 19)
                max_score = 19;
            else if (17 < score and score <= 18)
                max_score = 20;
            else if (16 < score and score <= 17)
                max_score = 21;
            else if (15 < score and score <= 16)
                max_score = 22;
            else if (score <= 15)
                max_score = 25;
  
  if (max_score >= 25) quit(_ok, "");
  if (max_score <= 0) quit(_wa, "");
  quitp(max_score / 25.0, "");
//    ouf.quitf(_ok, to_string(score).c_str());
}

Compilation message

Main.cpp:1:10: fatal error: testlib.h: No such file or directory
    1 | #include "testlib.h"
      |          ^~~~~~~~~~~
compilation terminated.