Submission #585840

#TimeUsernameProblemLanguageResultExecution timeMemory
585840SAADKeys (IOI21_keys)C++17
0 / 100
1 ms340 KiB
#define F first #define S second #define rep(i,a,b) for(int i=a;!(a==b&&i!=b)&&((i<=b&&b>=a)||(i>=b&&a>=b));i+=(a<=b?1:-1)) #define pb push_back #define Fbitl __builtin_ffs #define bit1 __builtin_popcount #include <iostream> #include <math.h> #include <algorithm> #include <string.h> #include <vector> #include <queue> #include <map> #include <unordered_map> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<string, string> pss; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vii; typedef vector<ll> vl; typedef vector<vl> vvl; vi want[2005]; vii road[2005]; bool vis[2005]; bool av[2005]; vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { vector<int> ans(r.size(), 0); for (int i = 0; i < u.size(); i++) { road[u[i]].push_back({v[i],c[i]}); road[v[i]].push_back({u[i],c[i]}); } for (int i = 0; i < ans.size(); i++) { memset(av, false, sizeof(av)); memset(vis, false, sizeof(vis)); for (auto& i : want) { i.clear(); } priority_queue < pair<bool, pii>> q; q.push({true,{i,r[i]} }); while (!q.empty()) { bool A = q.top().first; int key = q.top().second.second; int t = q.top().second.first; q.pop(); ans[i]++; av[r[t]] = true; vis[t] = true; if (!want[r[t]].empty()) { for (auto j : want[r[t]] ) { if (vis[j]) continue; q.push({true,{j,r[t]} }); vis[j] = true; } want[r[t]].clear(); } for (auto j : road[t]) { if (vis[j.first]) continue; if (av[j.S]) { q.push({ true,{j.F,j.S} }); vis[j.first] = true; } else { want[j.S].push_back(j.F); } } } } 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:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for (int i = 0; i < u.size(); i++) {
      |                  ~~^~~~~~~~~~
keys.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for (int i = 0; i < ans.size(); i++) {
      |                  ~~^~~~~~~~~~~~
keys.cpp:48:9: warning: unused variable 'A' [-Wunused-variable]
   48 |    bool A = q.top().first;
      |         ^
keys.cpp:49:8: warning: unused variable 'key' [-Wunused-variable]
   49 |    int key = q.top().second.second;
      |        ^~~
#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...