Submission #566624

#TimeUsernameProblemLanguageResultExecution timeMemory
566624drdilyorLottery (CEOI18_lot)C++17
65 / 100
3064 ms16104 KiB
#ifdef ONPC //#define _GLIBCXX_DEBUG #define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif #define allit(a) (a).begin(), (a).end() #define memclr(a) memset(a, 0, sizeof(0)) #define sz(a) ((int) (a).size()) #include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using vi = vector<int>; using vii = vector<pair<int, int>>; using vvi = vector<vector<int>>; template<typename T> using uset = unordered_set<T>; template<typename K, typename V> using umap = unordered_map<K, V>; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> namespace pd = __gnu_pbds; template<typename K> using ordered_set = pd::tree< K, pd::null_type, less<int>, pd::rb_tree_tag, pd::tree_order_statistics_node_update>; using pd::gp_hash_table; template <typename K> using fast_set = pd::gp_hash_table<K, pd::null_type>; void debug_out() { cerr << endl; } template<typename... Tail> void debug_out(vector<int> h, Tail... t) { cerr << "["; for (int i = 0; i < sz(h); i++) { if (i != 0) cerr << ", "; cerr << h[i]; } cerr << "]"; debug_out(t...); } template<typename P1, typename P2, typename... Tail> void debug_out(pair<P1, P2> h, Tail... t) { cerr << "[" << h.first << ", " << h.second << "]"; debug_out(t...); } template<typename Head, typename... Tail> void debug_out(Head h, Tail... t) { cerr << "[" << h << "]"; debug_out(t...); } const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); struct chash { int operator() (int x) const { return x ^ RANDOM; } }; const int INF = 1e9+1; const ll INFL = 1e18+1; const int N = 1e5; const int MOD = 1000000007; int solve(); signed main() { cin.tie(0)->sync_with_stdio(0); int t = 1; //cin >> t; while (t-- && cin) { if (solve()) break; #ifdef ONPC cout << "____________________" << endl; #endif } return 0; } ll pow(ll n, ll e, ll m) { ll res = 1; while (e) { if (e & 1) { res = (res * n) % m; } n = (n * n) % m; e >>= 1; } return res; } int n, l, qt; vi a, q; void solve_1_2(); void solve_3(); int solve() { cin >> n >> l; a.resize(n); for (auto& i : a) cin >> i; cin >> qt; q.resize(qt); for (auto& i : q) cin >> i; if (qt == 1 && q.back() == 0) solve_3(); else solve_1_2(); return 0; } void solve_1_2() { int diff[2000][2000]; memset(diff, 0, sizeof(diff)); for (int i1 = 0; i1 <= n - l; i1++) { for (int i2 = i1+1; i2 <= n - l; i2++) { int d = 0; for (int j = 0; j < l; j++) { if (a[i1+j] != a[i2+j]) d++; } diff[i1][i2] = d; } } for (int k : q) { vi res(n-l+1); for (int i1 = 0; i1 <= n - l; i1++) { for (int i2 = i1+1; i2 <= n -l; i2++) { if (diff[i1][i2] <= k) { res[i1]++; res[i2]++; } } } for (int i : res) { cout << i << ' '; } cout << '\n'; } } void solve_3() { for (auto& i : q) cin >> i; // sort all subarrays of len l vi as(n-l+1); for (int i = 0;i < sz(as);i++) as[i] = i; sort(allit(as), [&](int i, int j) { for (int k = 0; k < l; k++) { if (a[i+k] != a[j+k]) { return a[i+k] < a[j+k]; } } return false; }); debug(as); vi res(n-l+1); for (int i = 0; i <= n-l;) { int start = i; while (++i <= n-l) { int bad = 0; for (int j = 0; !bad && j < l; j++) { bad |= a[as[start]+j] != a[as[i]+j]; } if (bad) break; } for (int j = start; j < i; j++) { res[as[j]] = i - start - 1; } debug(start, i); } for (int i : res) cout << i << ' '; }

Compilation message (stderr)

lot.cpp: In function 'void solve_3()':
lot.cpp:5:24: warning: statement has no effect [-Wunused-value]
    5 |     #define debug(...) 42
      |                        ^~
lot.cpp:158:5: note: in expansion of macro 'debug'
  158 |     debug(as);
      |     ^~~~~
lot.cpp:5:24: warning: statement has no effect [-Wunused-value]
    5 |     #define debug(...) 42
      |                        ^~
lot.cpp:172:9: note: in expansion of macro 'debug'
  172 |         debug(start, i);
      |         ^~~~~
#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...