結果
問題 | No.812 Change of Class |
ユーザー |
|
提出日時 | 2019-04-12 21:53:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 4,901 bytes |
コンパイル時間 | 669 ms |
コンパイル使用メモリ | 76,156 KB |
最終ジャッジ日時 | 2024-11-14 21:25:05 |
合計ジャッジ時間 | 2,604 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'std::vector<_Tp> dijkstra(WeightedGraph<T>&, int)': main.cpp:86:22: error: 'numeric_limits' was not declared in this scope 86 | const auto INF = numeric_limits< T >::max(); | ^~~~~~~~~~~~~~ main.cpp:86:40: error: expected primary-expression before '>' token 86 | const auto INF = numeric_limits< T >::max(); | ^ main.cpp:86:46: error: no matching function for call to 'max()' 86 | const auto INF = numeric_limits< T >::max(); | ~~~~~^~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:50, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:38, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39, from main.cpp:1: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: main.cpp:86:46: note: candidate expects 2 arguments, 0 provided 86 | const auto INF = numeric_limits< T >::max(); | ~~~~~^~ /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp
ソースコード
#include <iostream>#include <algorithm>#include <vector>#include <string.h>#include <cassert>#include <queue>#include <tuple>using namespace std;using lint = long long;const lint mod = 1000000007;#define all(x) (x).begin(), (x).end()#define bitcount(n) __builtin_popcountl((lint)(n))#define fcout cout << fixed << setprecision(15)#define highest(x) (63 - __builtin_clzl(x))template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } returnans; }lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}};template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){return x; }template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){return a / gcd(a, b) * b; }struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] =fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lintC(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) ==max_bound){ (*now) = 0; }else{ return true; } } return false; }template< typename T >struct edge {int src, to;T cost;edge(int to, T cost) : src(-1), to(to), cost(cost) {}edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}edge &operator=(const int &x) {to = x;return *this;}operator int() const { return to; }};template< typename T >using Edges = vector< edge< T > >;template< typename T >using WeightedGraph = vector< Edges< T > >;using UnWeightedGraph = vector< vector< int > >;template< typename T >using Matrix = vector< vector< T > >;struct UnionFind{vector< int > data;UnionFind(int sz){data.assign(sz, -1);}bool unite(int x, int y){x = find(x), y = find(y);if(x == y) return(false);if(data[x] > data[y]) swap(x, y);data[x] += data[y];data[y] = x;return(true);}int find(int k){if(data[k] < 0) return(k);return(data[k] = find(data[k]));}int size(int k){return(-data[find(k)]);}};template< typename T >vector< T > dijkstra(WeightedGraph< T > &g, int s){const auto INF = numeric_limits< T >::max();vector< T > dist(g.size(), INF);using Pi = pair< T, int >;priority_queue< Pi, vector< Pi >, greater< Pi > > que;dist[s] = 0;que.emplace(dist[s], s);while(!que.empty()) {T cost;int idx;tie(cost, idx) = que.top();que.pop();if(dist[idx] < cost) continue;for(auto &e : g[idx]) {auto next_cost = cost + e.cost;if(dist[e.to] <= next_cost) continue;dist[e.to] = next_cost;que.emplace(dist[e.to], e.to);}}return dist;}int main(){int N, M;cin >> N >> M;;WeightedGraph<int> roads(N);for(int i = 0; i < M; i++){int p, q;cin >> p >> q;p--, q--;roads[p].push_back(edge<int>(q, 1));roads[q].push_back(edge<int>(p, 1));}int Q;cin >> Q;for(int i = 0; i < Q; i++){int A;cin >> A;A--;auto dist = dijkstra(roads, A);int ans = 0, sum = 0;for(int j = 0; j < N; j++){if(dist[j] < 1e9){sum++;ans = max(ans, dist[j]);}}ans--;int ans2 = 0;while(ans > 0){ans /= 2;ans2++;}cout << sum - 1 << " " << ans2 << endl;}}