제출 #530332

#제출 시각아이디문제언어결과실행 시간메모리
530332abc864197532Lottery (CEOI18_lot)C++17
45 / 100
147 ms65540 KiB
#include <bits/stdc++.h> using namespace std; #define lli long long int #define mp make_pair #define pb push_back #define eb emplace_back #define X first #define Y second #define pii pair<int,int> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() void abc() {cout << endl;} template <typename T, typename ...U> void abc(T i, U ...j) { cout << i << ' ', abc(j...); } template <typename T> void printv(T l, T r) { for (; l != r; ++l) cout << *l << " \n"[l + 1 == r]; } #ifdef Doludu #define test(x...) abc("[" + string(#x) + "]", x); #else #define test(x...) void(0); #endif const int N = 2000; int main () { ios::sync_with_stdio(false); cin.tie(0); int n, len; cin >> n >> len; vector <vector <int>> res(n + 1, vector <int> (n + 1, 0)); // diff, start vector <int> a(n), v; for (int i = 0; i < n; ++i) { cin >> a[i]; } v = a; sort(all(v)), v.resize(unique(all(v)) - v.begin()); vector <vector <int>> to_pos(v.size()); for (int i = 0; i < n; ++i) to_pos[lower_bound(all(v), a[i]) - v.begin()].pb(i); for (int x = 0; x < v.size(); ++x) { for (int i = 0; i < to_pos[x].size(); ++i) for (int j = i + 1; j < to_pos[x].size(); ++j) { int a = to_pos[x][i], b = to_pos[x][j]; // x + i = a, y + i = b, a - len < st <= a // y - x = b - a // a - len + 1 <= st < a + 1 int d = b - a; int bound = max(n - d - len + 1, 0); test(d, a, b, max(a - len + 1, 0), min(a + 1, bound)); res[d][max(a - len + 1, 0)]++; res[d][min(a + 1, bound)]--; } } for (int d = 1; d <= n; ++d) { for (int i = 1; i <= n; ++i) { res[d][i] += res[d][i - 1]; } } int q; cin >> q; while (q--) { int x; cin >> x; vector <int> ans(n - len + 1); for (int i = 0; i + len <= n; ++i) { for (int d = 1; i + d + len <= n; ++d) { if (res[d][i] >= len - x) ans[i]++, ans[i + d]++; } } printv(all(ans)); } }

컴파일 시 표준 에러 (stderr) 메시지

lot.cpp: In function 'int main()':
lot.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for (int x = 0; x < v.size(); ++x) {
      |                  ~~^~~~~~~~~~
lot.cpp:43:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for (int i = 0; i < to_pos[x].size(); ++i) for (int j = i + 1; j < to_pos[x].size(); ++j) {
      |                   ~~^~~~~~~~~~~~~~~~~~
lot.cpp:43:68: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for (int i = 0; i < to_pos[x].size(); ++i) for (int j = i + 1; j < to_pos[x].size(); ++j) {
      |                                                                  ~~^~~~~~~~~~~~~~~~~~
#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...