Submission #2973751
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; const int INF = 1000000000; const ll LINF = (ll) 4000000000000000000; const ll MOD = (ll) 1000000007; const double PI = acos(-1.0); const int limit = 100010; #define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i) #define rep(i,n) REP(i, 0, n) #define MP make_pair #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl #define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl #define NP(v) next_permutation(v.begin(),v.end()) #define smaller_queue priority_queue <ll, vector<ll>, greater<ll> > #define smaller_queue_p priority_queue <pll, vector<pll>, greater<pll> > //------------------------------------------------------ template <typename T, typename U> class dijkstra { public: struct edge { T to; U cost; }; using P = pair<U, T>; map<T, vector<edge> > E; map<T, U> d; void calc(T s) { priority_queue <P, vector<P>, greater<P> > que; rep(i, limit) d[i] = INF; que.emplace(U(0), s); d[s] = U(0); while (!que.empty()) { P p = que.top(); que.pop(); T v = p.second; if (d[v] < p.first) continue; for (auto&& e : E[v]) { //if (d.find(e.to) == d.end()) d[e.to] = INF; if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; que.emplace(d[e.to], e.to); } } } } }; int main() { cin.tie(0); ios::sync_with_stdio(false); int k; cin >> k; dijkstra<int, int> ds; rep(i, k) ds.E[i].push_back({(i + 1) % k, 1}); rep(i, k) ds.E[i].push_back({10 * i % k, 0}); ds.calc(1); cout << ds.d[0] + 1 << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Small Multiple |
User | stoq |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1992 Byte |
Status | AC |
Exec Time | 271 ms |
Memory | 16512 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:68:42: warning: narrowing conversion of ‘((i + 1ll) % ((ll)k))’ from ‘ll {aka long long int}’ to ‘int’ inside { } [-Wnarrowing] rep(i, k) ds.E[i].push_back({(i + 1) % k, 1}); ^ ./Main.cpp:69:41: warning: narrowing conversion of ‘((i * 10ll) % ((ll)k))’ from ‘ll {aka long long int}’ to ‘int’ inside { } [-Wnarrowing] rep(i, k) ds.E[i].push_back({10 * i % k, 0}); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 21 ms | 5120 KB |
02.txt | AC | 21 ms | 4992 KB |
03.txt | AC | 24 ms | 4992 KB |
04.txt | AC | 22 ms | 4992 KB |
05.txt | AC | 24 ms | 4992 KB |
06.txt | AC | 23 ms | 4992 KB |
07.txt | AC | 22 ms | 4992 KB |
08.txt | AC | 23 ms | 4992 KB |
09.txt | AC | 20 ms | 4992 KB |
10.txt | AC | 22 ms | 4992 KB |
11.txt | AC | 21 ms | 4992 KB |
12.txt | AC | 24 ms | 4992 KB |
13.txt | AC | 19 ms | 4992 KB |
14.txt | AC | 22 ms | 4992 KB |
15.txt | AC | 22 ms | 4992 KB |
16.txt | AC | 20 ms | 4992 KB |
17.txt | AC | 21 ms | 4992 KB |
18.txt | AC | 22 ms | 4992 KB |
19.txt | AC | 21 ms | 4992 KB |
20.txt | AC | 21 ms | 4992 KB |
21.txt | AC | 216 ms | 16000 KB |
22.txt | AC | 213 ms | 16000 KB |
23.txt | AC | 237 ms | 16512 KB |
24.txt | AC | 271 ms | 16512 KB |
25.txt | AC | 211 ms | 16256 KB |
26.txt | AC | 214 ms | 16256 KB |
27.txt | AC | 227 ms | 16508 KB |
28.txt | AC | 212 ms | 16508 KB |
29.txt | AC | 218 ms | 16256 KB |
30.txt | AC | 252 ms | 16512 KB |
31.txt | AC | 23 ms | 4992 KB |
32.txt | AC | 21 ms | 4992 KB |
33.txt | AC | 195 ms | 14080 KB |
34.txt | AC | 82 ms | 9344 KB |
35.txt | AC | 178 ms | 12928 KB |
36.txt | AC | 190 ms | 15488 KB |
37.txt | AC | 62 ms | 7680 KB |
38.txt | AC | 89 ms | 9472 KB |
39.txt | AC | 112 ms | 11008 KB |
40.txt | AC | 29 ms | 5632 KB |
41.txt | AC | 176 ms | 14720 KB |
42.txt | AC | 214 ms | 16000 KB |
43.txt | AC | 40 ms | 6272 KB |
44.txt | AC | 27 ms | 5376 KB |
45.txt | AC | 104 ms | 10752 KB |
46.txt | AC | 128 ms | 11776 KB |
47.txt | AC | 32 ms | 5632 KB |
48.txt | AC | 184 ms | 15152 KB |
49.txt | AC | 180 ms | 14464 KB |
50.txt | AC | 111 ms | 11136 KB |
51.txt | AC | 55 ms | 7424 KB |
52.txt | AC | 91 ms | 9856 KB |
53.txt | AC | 142 ms | 12800 KB |
54.txt | AC | 72 ms | 8704 KB |
55.txt | AC | 110 ms | 10752 KB |
56.txt | AC | 138 ms | 12800 KB |
57.txt | AC | 204 ms | 15872 KB |
58.txt | AC | 124 ms | 11648 KB |
59.txt | AC | 169 ms | 14080 KB |
60.txt | AC | 135 ms | 12416 KB |
61.txt | AC | 52 ms | 7168 KB |
62.txt | AC | 102 ms | 10496 KB |
63.txt | AC | 213 ms | 16000 KB |
64.txt | AC | 213 ms | 16000 KB |
s1.txt | AC | 21 ms | 4992 KB |
s2.txt | AC | 21 ms | 4992 KB |
s3.txt | AC | 166 ms | 13824 KB |