Submission #1095544

#TimeUsernameProblemLanguageResultExecution timeMemory
1095544cpptowinLottery (CEOI18_lot)C++17
35 / 100
297 ms5060 KiB
#include <bits/stdc++.h> #define fo(i, d, c) for (int i = d; i <= c; i++) #define fod(i, c, d) for (int i = c; i >= d; i--) #define maxn 1000010 #define N 1010 #define fi first #define se second #define pb emplace_back #define en cout << "\n"; #define bitcount(x) __builtin_popcountll(x) #define pii pair<int, int> #define vii vector<pii> #define lb(x) x & -x #define bit(i, j) ((i >> j) & 1) #define offbit(i, j) (i ^ (1LL << j)) #define onbit(i, j) (i | (1LL << j)) #define vi vector<int> #define all(x) x.begin(), x.end() #define ss(x) (int)x.size() template <typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) { a = b; return true; } return false; } template <typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) { a = b; return true; } return false; } using namespace std; const int nsqrt = 450; const int mod = 1e9 + 7; void add(int &x, int k) { x += k; x %= mod; if (x < 0) x += mod; } void del(int &x, int k) { x -= k; x %= mod; if (x < 0) x += mod; } int n, l, q; int res[10010][110], pos[10010]; int a[maxn]; main() { #define name "TASK" if (fopen(name ".inp", "r")) { freopen(name ".inp", "r", stdin); freopen(name ".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> l; fo(i, 1, n) cin >> a[i]; cin >> q; vi qq; fo(i, 1, q) { int x; cin >> x; qq.pb(x); pos[x] = i; } sort(all(qq)); fod(i, l, 0) if (!pos[i]) pos[i] = pos[i + 1]; fo(i, 1, n - l + 1) { int now = 0; fo(j, 1, l) if (a[i + j - 1] != a[j]) now++; if (i != 1) { res[i][pos[now]]++; res[1][pos[now]]++; } int u = i + l, v = l + 1; while (u <= n and v <= n) { if (a[u - l] != a[v - l]) now--; if (a[u] != a[v]) now++; if (u - l + 1 != v - l + 1) { res[u - l + 1][pos[now]]++; res[v - l + 1][pos[now]]++; } u++; v++; } } fo(i, 1, q - 1) fo(h, 1, n - l + 1) res[h][pos[qq[i]]] += res[h][pos[qq[i - 1]]]; fo(j, 1, q) { fo(i, 1, n - l + 1) cout << res[i][j] << ' '; en; } }

Compilation message (stderr)

lot.cpp:60:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   60 | main()
      | ^~~~
lot.cpp: In function 'int main()':
lot.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen(name ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen(name ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...