답안 #785217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
785217 2023-07-17T07:17:25 Z whatthemomooofun1729 사육제 (CEOI14_carnival) C++14
0 / 100
2 ms 208 KB
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#include <numeric>
//#include <bit>

#define INF 2e9
#define LL_INF 9223372036854775806
#define ff first
#define ss second
#define mod 1000000007
#define ll long long
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define EB emplace_back
#define PoB pop_back
#define LOG log2
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define fch(t, v) for (auto t : v)
#define sz(x) int(x.size())
#define rsz resize
#define gp(x) vector<vector<x>>
#define btree vector<pii>
#define vc(x) vector<x>
#define vll vector<ll>
#define Max(a, b, c) max(max(a,b),c)
#define fMax(a, b, c, d) max(Max(a, b, c), d)
#define Min(a, b, c) min(min(a,b),c)
#define Mid(a, b, c) max(min(a, b), min(max(a, b), c))
#define st(a) set<a>
#define gr(x) greater<x>
#define gi greater<int>
#define all(x) (x).begin(),(x).end()
#define tri(x) tuple<x,x,x>
#define quad(x) tuple<x,x,x,x>
#define eps 1e-9

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
void println() {cerr << ">--------------------<" << endl;}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

void setIO(const string& str) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if (str.empty()) return;
    freopen((str + ".in").c_str(), "r", stdin);
    freopen((str + ".out").c_str(), "w", stdout);
}

int N;
vi p, output;

int binary_search(int l, int r) {
    if (r < l) return 0;
    if (l == r) {
        output[l] = 1;
        return 1;
    }
    cout << r-l+1 << " ";
    for (int i = l; i <=r ; ++i) {
        cout << p[i] << " ";
    }
    cout << endl << flush;
    int x;
    cin >> x;
    if (r == l + 1) {
        if (x == 1) output[l] = output[r] = 1;
        else output[l] = 1, output[r] = 2;
        return x;
    } else {
        int mid = (l + r)/2;
        int left = binary_search(l, mid);
        int right = binary_search(mid+1, r);
        if (right < x) {
            for (int i = mid + 1; i<=r; i++) {
                output[i] += x-right;
            }
            cout << "2 " << p[mid] << " " << p[mid+1] << endl << flush;
            int x1;
            cin >> x1;
            if (x1 == 2 && output[mid] == output[mid+1]) {
                for (int i = mid + 1; i<=r; i++) {
                    output[i] --;
                }
            }
        }
        return x;
    }
}

int main() { // time yourself !!!
    setIO("");
    cin >> N;
    p.rsz(N), output.rsz(N);
    iota(all(p), 1);
    binary_search(0, N-1);
    cout << 0 << " ";
    for (int i = 0; i < sz(output); ++i) {
        cout << output[i] << " ";
    }
    cout << flush;
    return 0;
}

Compilation message

carnival.cpp: In function 'int binary_search(int, int)':
carnival.cpp:119:13: warning: unused variable 'left' [-Wunused-variable]
  119 |         int left = binary_search(l, mid);
      |             ^~~~
carnival.cpp: In function 'void setIO(const string&)':
carnival.cpp:93:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |     freopen((str + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:94:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |     freopen((str + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 2 ms 208 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -