답안 #176070

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
176070 2020-01-07T19:58:15 Z mat_v 사육제 (CEOI14_carnival) C++14
100 / 100
30 ms 380 KB
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define mid(l, r) ((l)+(r))/2
#define len(a) (a).length()
#define sz(a) (a).size()
#define xx first
#define yy second
#define inf int(2e9)
#define ff(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i, a, b) for(int (i) = (a); (i) >= (b); --(i))


using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

template<class T>
void print(const T niz[], const int siz)
{
    for(int i=0;i<siz;i++)
        cout << niz[i] << " ";
    cout << endl;
}

int n;
vector<int>upit;

int pitaj(int l, int r){
    upit.clear();
    ff(i,l,r)upit.pb(i);
    cout << upit.size() << " ";
    for(auto c:upit)cout << c << " ";
    cout << endl;
    int odg;
    cin >> odg;
    cout << endl;
    return odg;
}
bool znam[200];
int niz[200];
int nadjisl(int x){
    if(x == n)return n + 1;
    int l = 1;
    int r = n - x;
    int p = pitaj(x, n);
    int p2 = pitaj(x + 1, n);
    if(p > p2)return n + 1;
    while(l < r){
        int mid = (l + r) / 2;
        int sta = pitaj(x, x + mid);
        int sta2 = pitaj(x + 1, x + mid);
        if(sta > sta2){
            l = mid + 1;
        }
        else r = mid;
    }
    return x+l;
}
int main()
{
    ios_base::sync_with_stdio(false);
    int br = 1;
    cin >> n;
    ff(i,1,n){
        if(znam[i])continue;
        niz[i] = br;
        znam[i] = 1;
        int tr = i;
        while(1){
            tr = nadjisl(tr);
            znam[tr] = 1;
            niz[tr] = br;
            if(tr > n)break;
        }
        br++;
    }
    cout << 0 << " ";
    ff(i,1,n)cout << niz[i] << " ";
    cout << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 248 KB Output is correct
2 Correct 22 ms 248 KB Output is correct
3 Correct 12 ms 248 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 15 ms 248 KB Output is correct
6 Correct 22 ms 376 KB Output is correct
7 Correct 22 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 248 KB Output is correct
2 Correct 28 ms 376 KB Output is correct
3 Correct 11 ms 248 KB Output is correct
4 Correct 8 ms 248 KB Output is correct
5 Correct 25 ms 248 KB Output is correct
6 Correct 23 ms 376 KB Output is correct
7 Correct 30 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 248 KB Output is correct
2 Correct 15 ms 248 KB Output is correct
3 Correct 14 ms 376 KB Output is correct
4 Correct 10 ms 248 KB Output is correct
5 Correct 30 ms 248 KB Output is correct
6 Correct 14 ms 324 KB Output is correct
7 Correct 25 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 248 KB Output is correct
2 Correct 16 ms 332 KB Output is correct
3 Correct 12 ms 248 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
5 Correct 24 ms 248 KB Output is correct
6 Correct 16 ms 248 KB Output is correct
7 Correct 24 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 252 KB Output is correct
2 Correct 25 ms 376 KB Output is correct
3 Correct 18 ms 248 KB Output is correct
4 Correct 16 ms 248 KB Output is correct
5 Correct 11 ms 248 KB Output is correct
6 Correct 12 ms 296 KB Output is correct
7 Correct 10 ms 248 KB Output is correct