Submission #36411

# Submission time Handle Problem Language Result Execution time Memory
36411 2017-12-08T17:46:40 Z bnahmad15 Carnival (CEOI14_carnival) C++14
0 / 100
33 ms 2016 KB
#include <bits/stdc++.h>
#define forn(i,n) for(int i =0;i<int(n);i++)
#define nfor(i,n) for(int i =int(n)-1;i>=0;i--)
#define rep(i,j,n) for(int i = int(j);i <= int(n);i++)
#define rev(i,j,n) for(int i = int(j);i>=int(n);i--)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define oo 2000000000
#define ooo 2000000000000000000
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
const int N = 100010,MOD = 1000000007;
const double PI = acos(-1.0);
int gcd(int a,int b){return (b==0) ? a : gcd(b,a%b);}
string tostr(ll num){string res = "";while (num)res += char('0' + (num % 10)),num/=10;reverse(all(res));return res;}
string tobin(int num){string res="";while(num)res += char('0' + (num % 2)),num/=2;reverse(all(res));return res;}
ll tonum(string te){ll res = 0;forn(i,te.size())res *= 10LL,res += te[i]-'0';return res;}
int bit(vector <ll> &v,ll a,ll b){return upper_bound(all(v),b)-upper_bound(all(v),a-1);}
void fl(){fflush(stdout);}

int n,ans[155],cnt = 0;
int print(int left,int right){
    if (left >= right)
        return 1;
    int res;
    printf("%d",right-left+1);
    for (int i = left;i<=right;i++)
        printf(" %d",i);
    cout<<endl;
    scanf("%d",&res);
    return res;
}
int main(){

    scanf("%d",&n);
    memset(ans,-1,sizeof ans);
    for (int i = 1;i<=n;i++){
        if (ans[i] == -1)
            ans[i]=++cnt;
        int low = i,high = n,res = i;
        if (print(i,n) != print(i+1,n))
            continue;
        while (low<=high){
            int md = (low + high) / 2;
            int one = print(i,md);
            int two = print(i+1,md);
            if (one == two){
                res = md;
                high = md - 1;
            }
            else 
                low = md +1;
        }
        ans[res]=ans[i];
    }
    printf("0");
    for (int i= 1;i<=n;i++)
        printf(" %d",ans[i]);
    return 0;
}

Compilation message

carnival.cpp: In function 'int print(int, int)':
carnival.cpp:37:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&res);
                     ^
carnival.cpp: In function 'int main()':
carnival.cpp:42:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 2016 KB Integer 12 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 2016 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 2016 KB Integer 2 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2016 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 2016 KB Integer 3 violates the range [1, 2]
2 Halted 0 ms 0 KB -