Submission #387716

# Submission time Handle Problem Language Result Execution time Memory
387716 2021-04-09T06:14:17 Z 2qbingxuan Table Tennis (info1cup20_tabletennis) C++14
34 / 100
62 ms 4520 KB
#include <bits/stdc++.h>
#ifdef local
#define debug(a...) qqbx(#a, a)
template <typename ...T> void qqbx(const char *s, T ...a) {
    int cnt = sizeof...(T);
    ((std::cerr << "\033[1;32m(" << s << ") = (") , ... , (std::cerr << a << (--cnt ? ", " : ")\033[0m\n")));
}
#define pary(a...) danb(#a, a)
template <typename T> void danb(const char *s, T L, T R) {
    std::cerr << "\033[1;32m[ " << s << " ] = [ ";
    for (int f = 0; L != R; ++L) std::cerr << (f++ ? " " : "") << *L;
    std::cerr << " ]\033[0m\n";
}
#else
#define debug(...) ((void)0)
#define pary(...) ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define pb emplace_back

using namespace std;
using ll = int64_t;
const int inf = 1e9, MOD = 1000000007, maxn = 1 << 18, maxLg = 18;

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, k;
    cin >> n >> k;
    int m = n+k;
    vector<int> a(m);
    for (int i = 0; i < m; i++)
        cin >> a[i];
    int lim = min(m / 2, k * 2);

    vector<int> jizz(a.begin(), a.begin() + lim);
    jizz.insert(jizz.end(), a.end() - lim, a.end());

    map<int,int> freq;
    for (int x: jizz) for (int y: jizz) if (x < y) ++freq[x+y];
    for (auto [val, cnt]: freq) if (cnt >= k) {
        debug(val);
        vector<int> cur;
        for (int i = 0, j = a.size()-1; i < j; i++) {
            while (j > i && a[j] > val - a[i]) --j;
            if (j > i && a[j] + a[i] == val)
                cur.pb(a[i]), cur.pb(a[j]);
        }
        if (cur.size() == n) {
            sort(all(cur));
            for (int x: cur)
                cout << x << ' ';
            cout << '\n';
            return 0;
        }
    }
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:40:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   40 |     for (auto [val, cnt]: freq) if (cnt >= k) {
      |               ^
tabletennis.cpp:48:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |         if (cur.size() == n) {
      |             ~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 764 KB Output is correct
2 Correct 40 ms 3008 KB Output is correct
3 Correct 48 ms 3044 KB Output is correct
4 Correct 39 ms 3008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 3092 KB Output is correct
2 Correct 62 ms 3076 KB Output is correct
3 Correct 40 ms 3088 KB Output is correct
4 Correct 40 ms 3016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 716 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 4520 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -