Submission #803197

#TimeUsernameProblemLanguageResultExecution timeMemory
803197vjudge1Keys (IOI21_keys)C++17
37 / 100
79 ms21800 KiB
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int v,c;
};
vector<edge> adj[3010];
vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
    int n = r.size(), m = u.size();
	vector<int> res(n);
    for(int i = 0; i < m; i++)
        adj[u[i]].push_back({v[i], c[i]}),
        adj[v[i]].push_back({u[i], c[i]});
    for(int i = 0; i < n; i++) {
        bitset<2010> vis, ac;
        vector<int> unlock[2010];
        queue<int> q;
        q.push(i);
        vis[i] = 1;
        while(!q.empty()) {
            int x = q.front();
            q.pop();
            if(!ac[r[x]]) {
                ac[r[x]] = 1;
                for(auto j: unlock[r[x]]) {
                    if(!vis[j]) {
                        vis[j]=1;
                        q.push(j);
                    }
                }
            }
            for(auto j: adj[x]) {
                if(!vis[j.v]) {
                    if(ac[j.c])
                        q.push(j.v), vis[j.v]=1;
                    else
                        unlock[j.c].push_back(j.v);
                }
            }
        }
        res[i] = vis.count();
    }
    vector<int> ans(n);
    int x = *min_element(res.begin(), res.end());
    for(int i = 0; i < n; i++)
        ans[i] = (res[i]==x);
	return ans;
}

Compilation message (stderr)

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:44:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   44 |     for(int i = 0; i < n; i++)
      |     ^~~
keys.cpp:46:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   46 |  return ans;
      |  ^~~~~~
#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...