답안 #1028092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028092 2024-07-19T13:21:52 Z otarius 사육제 (CEOI14_carnival) C++17
100 / 100
17 ms 856 KB
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ull unsigned long long
#define all(x) (x).begin(),(x).end()

// #define int long long
// #define int unsigned long long

// #define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
// #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>

void open_file(string filename) {
    freopen((filename + ".in").c_str(), "r", stdin);
    freopen((filename + ".out").c_str(), "w", stdout);
}

// const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll inf = 1e9;
const ll biginf = 1e18;
// const int maxN;

void ask(vector<int> v) {
    cout << v.size() << ' ';
    for (int i : v) cout << i << ' ';
    cout << endl;
}
void solve() {
    int n;
    cin >> n;
    int clr[n + 1], cur = 1;
    clr[1] = cur;
    for (int i = 2; i <= n; i++) {
        vector<int> v;
        for (int j = 1; j < i; j++) v.pb(j);
        ask(v); int x1; cin >> x1; v.pb(i);
        ask(v); int x2; cin >> x2;
        if (x1 != x2) clr[i] = ++cur;
        else {
            int l = 1, r = i - 1, m, ans;
            while (l <= r) {
                m = (l + r) / 2;
                v.clear();
                for (int j = m; j < i; j++) v.pb(j);
                ask(v); int x1; cin >> x1; v.pb(i);
                ask(v); int x2; cin >> x2;
                if (x1 == x2) {
                    ans = m; l = m + 1;
                } else {
                    r = m - 1;
                }
            } clr[i] = clr[ans];
        }
    } cout << "0 ";
    for (int i = 1; i <= n; i++)
        cout << clr[i] << ' ';
    cout << endl;
}
int32_t main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Compilation message

carnival.cpp: In function 'void open_file(std::string)':
carnival.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((filename + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((filename + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp: In function 'void solve()':
carnival.cpp:66:31: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |             } clr[i] = clr[ans];
      |                        ~~~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 600 KB Output is correct
2 Correct 9 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 11 ms 600 KB Output is correct
6 Correct 16 ms 852 KB Output is correct
7 Correct 9 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 344 KB Output is correct
2 Correct 10 ms 592 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 3 ms 704 KB Output is correct
5 Correct 9 ms 592 KB Output is correct
6 Correct 17 ms 856 KB Output is correct
7 Correct 12 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 712 KB Output is correct
2 Correct 10 ms 344 KB Output is correct
3 Correct 9 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 9 ms 344 KB Output is correct
6 Correct 9 ms 344 KB Output is correct
7 Correct 9 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 344 KB Output is correct
2 Correct 11 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 10 ms 456 KB Output is correct
6 Correct 9 ms 344 KB Output is correct
7 Correct 10 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 600 KB Output is correct
2 Correct 13 ms 452 KB Output is correct
3 Correct 9 ms 456 KB Output is correct
4 Correct 9 ms 600 KB Output is correct
5 Correct 7 ms 460 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 6 ms 344 KB Output is correct