Submission #711983

#TimeUsernameProblemLanguageResultExecution timeMemory
711983stevancvBrunhilda’s Birthday (BOI13_brunhilda)C++14
Compilation error
0 ms0 KiB
#define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 1e5 + 2; const int M = 1e6 + 2; const int inf = 1e9; vector<int> primes[M]; int idx[M], ans[N], koji[M], dp[M]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; multiset<pair<int, int>> s; for (int i = 0; i < n; i++) { int x; cin >> x; s.insert({0, x}); for (int j = x; j < 1e7; j += x) primes[j].push_back(x); } for (int i = 1; i <= q; i++) { int x; cin >> x; idx[x] = i; } for (int i = 1; i < M; i++) { dp[i] = inf; for (int j : primes[i]) { s.erase({koji[j], j}); } if (!s.empty()) dp[i] = s.begin()->first + 1; if (idx[i] != 0) ans[idx[i]] = dp[i]; for (int j : primes[i]) { s.insert({dp[i], j}); koji[j] = dp[i]; } } for (int i = 1; i <= q; i++) { if (ans[i] >= inf) cout << "oo" << en; else cout << ans[i] << en; } return 0; }

Compilation message (stderr)

brunhilda.cpp:11:1: error: 'vector' does not name a type
   11 | vector<int> primes[M];
      | ^~~~~~
brunhilda.cpp: In function 'int main()':
brunhilda.cpp:14:5: error: 'ios' has not been declared
   14 |     ios::sync_with_stdio(false);
      |     ^~~
brunhilda.cpp:15:5: error: 'cin' was not declared in this scope
   15 |     cin.tie(0);
      |     ^~~
brunhilda.cpp:1:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | #define ll long long
brunhilda.cpp:16:5: error: 'cout' was not declared in this scope
   16 |     cout.tie(0);
      |     ^~~~
brunhilda.cpp:16:5: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
brunhilda.cpp:19:5: error: 'multiset' was not declared in this scope
   19 |     multiset<pair<int, int>> s;
      |     ^~~~~~~~
brunhilda.cpp:1:1: note: 'std::multiset' is defined in header '<set>'; did you forget to '#include <set>'?
  +++ |+#include <set>
    1 | #define ll long long
brunhilda.cpp:19:14: error: 'pair' was not declared in this scope
   19 |     multiset<pair<int, int>> s;
      |              ^~~~
brunhilda.cpp:1:1: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
  +++ |+#include <utility>
    1 | #define ll long long
brunhilda.cpp:19:19: error: expected primary-expression before 'int'
   19 |     multiset<pair<int, int>> s;
      |                   ^~~
brunhilda.cpp:22:9: error: 's' was not declared in this scope
   22 |         s.insert({0, x});
      |         ^
brunhilda.cpp:23:42: error: 'primes' was not declared in this scope
   23 |         for (int j = x; j < 1e7; j += x) primes[j].push_back(x);
      |                                          ^~~~~~
brunhilda.cpp:31:22: error: 'primes' was not declared in this scope
   31 |         for (int j : primes[i]) {
      |                      ^~~~~~
brunhilda.cpp:32:13: error: 's' was not declared in this scope
   32 |             s.erase({koji[j], j});
      |             ^
brunhilda.cpp:34:14: error: 's' was not declared in this scope
   34 |         if (!s.empty()) dp[i] = s.begin()->first + 1;
      |              ^
brunhilda.cpp:36:22: error: 'primes' was not declared in this scope
   36 |         for (int j : primes[i]) {
      |                      ^~~~~~
brunhilda.cpp:37:13: error: 's' was not declared in this scope
   37 |             s.insert({dp[i], j});
      |             ^