Submission #825928

#TimeUsernameProblemLanguageResultExecution timeMemory
825928LittleCubeThousands Islands (IOI22_islands)C++17
1.75 / 100
32 ms10648 KiB
#include "islands.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define F first
#define S second
using namespace std;

namespace
{
    int K;
    vector<int> path, vis, use;
    vector<pii> E[100000], R[100000];
    int dfs(int u)
    {
        vis[u] = 1;
        path.emplace_back(u);
        for (auto [v, i] : E[u])
            if (vis[v] == 0 && !use[i])
            {
                use[i] = 1;
                int res = dfs(v);
                if (res != -1)
                    return res;
                use[i] = 0;
            }
            else if (vis[v] == 1 && !use[i])
            {
                use[i] = 1;
                return v;
            }
        path.pop_back();
        return -1;
    }
}

variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V)
{
    for (int i = 0; i < M; i++)
        E[U[i]].emplace_back(pii(V[i], i));

    vis.resize(N, 0);
    use.resize(M, 0);
    int res = dfs(0);
    path.emplace_back(res);
    vector<int> ch1, cyc1;
    {
        int i = 0;
        for (; i < path.size(); i++)
        {
            ch1.emplace_back(i);
            if (path[i] == res)
                break;
        }
        i++;
        for (; i < path.size(); i++)
            cyc1.emplace_back(i);
        path.clear();
    }
    for (int i : ch1)
    {
        int res = dfs(i);
        if (res >= 0)
            return true;
        vis[i] = 2;
    }
    return false;
}

Compilation message (stderr)

islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:49:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for (; i < path.size(); i++)
      |                ~~^~~~~~~~~~~~~
islands.cpp:56:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         for (; i < path.size(); i++)
      |                ~~^~~~~~~~~~~~~
islands.cpp: At global scope:
islands.cpp:11:9: warning: '{anonymous}::K' defined but not used [-Wunused-variable]
   11 |     int K;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...