QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#551893#3675. Interactive Array GuessingTEAM1_AUCA#RE 1ms3592kbC++176.5kb2024-09-07 18:51:342024-09-07 18:51:34

Judging History

This is the latest submission verdict.

  • [2024-09-07 18:51:34]
  • Judged
  • Verdict: RE
  • Time: 1ms
  • Memory: 3592kb
  • [2024-09-07 18:51:34]
  • Submitted

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("O3")
// #pragma unroll

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<std::string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<vll> vvll;
typedef std::vector<std::pair<int, int>> vpi;
typedef std::vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;
typedef std::vector<vpll> vvpll;

const long long mod = 1e9 + 7;
// const long long mod = 998244353;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
/*
const unsigned gen_seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);
*/

#define _GLIBCXX_DEBUG 1
#define _GLIBCXX_DEBUG_PEDANTIC 1
#define _FORTIFY_SOURCE 2

#define I_am_clown               \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define srt(c) sort(all(c))
#define srtrev(c) sort(rall(c))
#define forn(i, a, b) for (ll i = a; i < b; i++)
#define read(x) scanf("%d", &x)
#define readv(x, n) \
    vll x(n);       \
    forn(i, 0, n) scanf("%u", &x[i])

#define pb push_back
#define mp make_pair
#define yes cout << "YES\n";
#define no cout << "NO\n";

#define sz(a) a.size()

using namespace __gnu_cxx;
using namespace std;

// benq - print any container + pair
template <typename T, typename = void>
struct is_iterable : false_type
{
};
template <typename T>
struct is_iterable<T, void_t<decltype(begin(declval<T>())), decltype(end(declval<T>()))>> : true_type
{
};
template <typename T>
typename enable_if<is_iterable<T>::value && !is_same<T, string>::value, ostream &>::type operator<<(ostream &cout, T const &v);
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.first << ", " << p.second << ")"; }
template <typename T>
typename enable_if<is_iterable<T>::value && !is_same<T, string>::value, ostream &>::type operator<<(ostream &cout, T const &v)
{
    cout << "[";
    for (auto it = v.begin(); it != v.end();)
    {
        cout << *it;
        if (++it != v.end())
            cout << ", ";
    }
    return cout << "]";
}
template <typename A, typename B>
istream &operator>>(istream &cin, pair<A, B> &p)
{
    cin >> p.first;
    return cin >> p.second;
}

template <typename T>
void debug(string s, T x) { cerr << "\033[1;34m" << s << "\033[0;32m = \033[35m" << x << "\033[0m\n"; }
template <typename T, typename... Args>
void debug(string s, T x, Args... args)
{
    for (int i = 0, b = 0; i < (int)s.size(); i++)
        if (s[i] == '(' || s[i] == '{')
            b++;
        else if (s[i] == ')' || s[i] == '}')
            b--;
        else if (s[i] == ',' && b == 0)
        {
            cerr << "\033[1;34m" << s.substr(0, i) << "\033[0;32m = \033[35m" << x << "\033[31m | ";
            debug(s.substr(s.find_first_not_of(' ', i + 1)), args...);
            break;
        }
}
template <typename T>
void debug_nameless(T x) { cerr << "\033[35m" << x << "\033[0m\n"; }
template <typename T, typename... Args>
void debug_nameless(T x, Args... args)
{
    cerr << "\033[35m" << x << "\033[31m | ";
    debug_nameless(args...);
}

#ifdef temirbek_local
#define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__)
#define dbgs(...) debug_nameless(__VA_ARGS__)
#else
#define dbg(...) 135
#define dbgs(...) 135
#endif

const long long int MAXN = 1e18 + 2;

class Timer
{
    std::chrono::time_point<std::chrono::steady_clock> timePoint;
    size_t value;

public:
    void start() { timePoint = std::chrono::steady_clock::now(); }
    void finish()
    {
        auto curr = std::chrono::steady_clock::now();
        auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(curr - timePoint);
        value = elapsed.count();
    }
    size_t operator()() const { return value; }
};

Timer timer;

void ask(ll m, vll q)
{
    cout << "? " << m << " ";
    forn(i, 0, m)
    {
        cout << q[i] << " ";
    }
    cout << "\n";
    cout.flush();
}

void answer(vvll a)
{
    cout << "! ";
    forn(i, 0, a.size())
    {
        cout << a[i].size() << " ";
        forn(j, 0, a[i].size())
        {
            cout << a[i][j] << " ";
        }
    }
    cout.flush();
}

void solve()
{
    ll n;
    cin >> n;
    vvll a(n);
    if (n % 2 == 1)
    {
        ask(1, {n});
        ll m;
        cin >> m;
        forn(i, 0, m)
        {
            ll x;
            cin >> x;
            a[n - 1].pb(x);
        }
        n--;
    }
    ll half = n / 2;
    vll q;
    for (ll i = 1; i <= half; i++)
    {
        q.pb(i);
        q.pb(i);
    }
    ask(q.size(), q);
    ll m;
    cin >> m;
    vll b(m);
    forn(i, 0, m)
    {
        cin >> b[i];
    }
    ll start = 0;
    for (ll i = 1; i <= half; i++)
    {
        ll f = b[start];
        a[i - 1].pb(b[start]);
        forn(j, start + 1, m)
        {
            if (b[j] == f)
            {
                start = j + a[i - 1].size();
                break;
            }
            a[i - 1].pb(b[j]);
        }
    }
    q.clear();
    forn(i, half + 1, n + 1)
    {
        q.pb(i);
        q.pb(i);
    }
    ask(q.size(), q);
    cin >> m;
    vll c(m);
    forn(i, 0, m)
    {
        cin >> c[i];
    }
    start = 0;
    for (ll i = half + 1; i <= n; i++)
    {
        ll f = c[start];
        a[i - 1].pb(c[start]);
        forn(j, start + 1, m)
        {
            if (c[j] == f)
            {
                start = j + a[i - 1].size();
                break;
            }
            a[i - 1].pb(c[j]);
        }
    }
    answer(a);
    return;
}

void naive()
{
    return;
}

int main()
{
    I_am_clown;

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int T = 1;
    // cin >> T;
#ifdef temirbek_local
    timer.start();
#endif
    while (T--)
    {
        solve();
        // naive();
    }
#ifdef temirbek_local
    timer.finish();
    cout << timer() << " ms"
         << "\n";
#endif
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

input:

3
2 2 1
2 1 1
4 1 2 1 2

output:

? 1 3 
? 2 1 1 
? 2 2 2 
! 1 1 2 1 2 2 2 1 

result:

ok 3 arrays, sum_len = 5

Test #2:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

3
3 1 4 2
4 2 3 2 3
2 2 2

output:

? 1 3 
? 2 1 1 
? 2 2 2 
! 2 2 3 1 2 3 1 4 2 

result:

ok 3 arrays, sum_len = 6

Test #3:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

3
2 2 1
4 1 2 1 2
4 1 2 1 2

output:

? 1 3 
? 2 1 1 
? 2 2 2 
! 2 1 2 2 1 2 2 2 1 

result:

ok 3 arrays, sum_len = 6

Test #4:

score: -100
Runtime Error

input:

1
1 3

output:

? 1 1 
? 0 

result: