Submission #597871

# Submission time Handle Problem Language Result Execution time Memory
597871 2022-07-17T03:10:44 Z yanndev Simurgh (IOI17_simurgh) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int IDK = 0;
const int NOT_ROYAL = 1;
const int ROYAL = 2;

vector<pair<int, int>> graph[542];
vector<int> back[542];
bool vis[542];
bool dfsTree[4242];
int status[4242];

void dfs(int node, int root, int subId = -1) {
    vis[node] = true;
    for (auto& x: graph[node]) {
        if (vis[x.fi] && x.fi == root)
            back[subId].push_back(x.se);
        int nxtId = subId;
        if (subId == -1)
            nxtId = x.fi;
        dfsTree[x.se] = true;
        dfs(x.fi, root, nxtId);
    }
}

vector<int> find_roads(int n, vector<int> u, vector<int> v) {
    int m = (int)u.size();
    for (int i = 0; i < m; i++) {
        graph[u[i]].push_back({v[i], i});
        graph[v[i]].push_back({u[i], i});
    }

    for (int i = 0; i < n; i++) {
        memset(vis, false, sizeof(vis));
        memset(dfsTree, false, sizeof(vis));
        for (int j = 0; j < n; j++)
            back[j].clear();
        
        dfs(i, i, -1);
        for (auto& x: graph[i]) {
            // x.se a royal edge ???
            if (status[x.se] != IDK)
                continue;

            vector<int> toQ {};
            for (int j = 0; j < m; j++)
                if (dfsTree[j] && j != x.se)
                    toQ.push_back(j);
            toQ.push_back(x.se);
            int orig = count_common_roads(toQ);
            status[x.se] = ROYAL;

            for (auto& y: back[x.fi]) {
                toQ.pop_back();
                toQ.push_back(y);
                int newCnt = count_common_roads(toQ);
                if (newCnt > orig) {
                    status[x.se] = NOT_ROYAL;
                    status[y] = ROYAL;
                }
            }
        }
    }

    vector<int> ans {};
    for (int i = 0; i < m; i++)
        if (status[i] == ROYAL)
            ans.push_back(i);
    return ans;
}

Compilation message

simurgh.cpp: In function 'void dfs(int, int, int)':
simurgh.cpp:17:19: error: 'struct std::pair<int, int>' has no member named 'fi'
   17 |         if (vis[x.fi] && x.fi == root)
      |                   ^~
simurgh.cpp:17:28: error: 'struct std::pair<int, int>' has no member named 'fi'
   17 |         if (vis[x.fi] && x.fi == root)
      |                            ^~
simurgh.cpp:18:37: error: 'struct std::pair<int, int>' has no member named 'se'
   18 |             back[subId].push_back(x.se);
      |                                     ^~
simurgh.cpp:21:23: error: 'struct std::pair<int, int>' has no member named 'fi'
   21 |             nxtId = x.fi;
      |                       ^~
simurgh.cpp:22:19: error: 'struct std::pair<int, int>' has no member named 'se'
   22 |         dfsTree[x.se] = true;
      |                   ^~
simurgh.cpp:23:15: error: 'struct std::pair<int, int>' has no member named 'fi'
   23 |         dfs(x.fi, root, nxtId);
      |               ^~
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:43:26: error: 'struct std::pair<int, int>' has no member named 'se'
   43 |             if (status[x.se] != IDK)
      |                          ^~
simurgh.cpp:48:42: error: 'struct std::pair<int, int>' has no member named 'se'
   48 |                 if (dfsTree[j] && j != x.se)
      |                                          ^~
simurgh.cpp:50:29: error: 'struct std::pair<int, int>' has no member named 'se'
   50 |             toQ.push_back(x.se);
      |                             ^~
simurgh.cpp:51:24: error: 'count_common_roads' was not declared in this scope
   51 |             int orig = count_common_roads(toQ);
      |                        ^~~~~~~~~~~~~~~~~~
simurgh.cpp:52:22: error: 'struct std::pair<int, int>' has no member named 'se'
   52 |             status[x.se] = ROYAL;
      |                      ^~
simurgh.cpp:54:34: error: 'struct std::pair<int, int>' has no member named 'fi'
   54 |             for (auto& y: back[x.fi]) {
      |                                  ^~
simurgh.cpp:59:30: error: 'struct std::pair<int, int>' has no member named 'se'
   59 |                     status[x.se] = NOT_ROYAL;
      |                              ^~