Submission #146209

# Submission time Handle Problem Language Result Execution time Memory
146209 2019-08-22T20:12:25 Z cfalas Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
362 ms 8540 KB
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MOD 1000000007
#define INF 1000000
#define mp make_pair
#define ll long long
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef map<ll,ll> mii;
#define it(x) x::iterator
#define FOR(i,a,b) for(int i=a;i<b;i++)

#define gcd __gcd

int main(){
    int n, k;
    cin>>n>>k;
    int b[30] = {};
    int a[n];
    int mina = 30-(n+k-1);
    FOR(i,0,n){ cin>>a[i]; b[a[i]]++; }
    int tot = 0;
    FOR(i,0,n) tot+=(1<<(a[i]));
    int remainingbin = ((1<<30)-tot);
    int remaining=-1;
    while(remainingbin>0){
        remaining++;
        remainingbin/=2;
    }
    bool done = false;
    if(!done && n>=2 && (a[0]<=a[1] && remaining<=a[0] || a[0]>=a[1] && remaining>=a[0])){
        cout<<remaining<<" ";
        done = true;
    }
    cout<<a[0]<<" ";
    for(int i=1;i<n;i++){
        if(!done && remaining>=a[i-1] && a[i]>=remaining || remaining<=a[i-1] && a[i]<=remaining){ cout<<remaining<<" "; done = true;}
        cout<<a[i]<<" ";
    }
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:34:37: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if(!done && n>=2 && (a[0]<=a[1] && remaining<=a[0] || a[0]>=a[1] && remaining>=a[0])){
                          ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
zalmoxis.cpp:40:39: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         if(!done && remaining>=a[i-1] && a[i]>=remaining || remaining<=a[i-1] && a[i]<=remaining){ cout<<remaining<<" "; done = true;}
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
zalmoxis.cpp:23:9: warning: unused variable 'mina' [-Wunused-variable]
     int mina = 30-(n+k-1);
         ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 361 ms 8312 KB Expected EOF
2 Incorrect 352 ms 8440 KB Expected EOF
3 Incorrect 353 ms 8312 KB Expected EOF
4 Incorrect 350 ms 8440 KB Expected EOF
5 Incorrect 355 ms 8460 KB Expected EOF
6 Incorrect 348 ms 8312 KB Expected EOF
# Verdict Execution time Memory Grader output
1 Incorrect 362 ms 8440 KB Unexpected end of file - int32 expected
2 Incorrect 353 ms 8392 KB Unexpected end of file - int32 expected
3 Incorrect 358 ms 8440 KB Unexpected end of file - int32 expected
4 Incorrect 362 ms 8464 KB Unexpected end of file - int32 expected
5 Incorrect 354 ms 8540 KB Unexpected end of file - int32 expected
6 Incorrect 351 ms 8440 KB Unexpected end of file - int32 expected
7 Incorrect 353 ms 8468 KB Unexpected end of file - int32 expected
8 Incorrect 352 ms 8516 KB Expected EOF
9 Incorrect 282 ms 6812 KB Unexpected end of file - int32 expected
10 Incorrect 108 ms 2808 KB Unexpected end of file - int32 expected
11 Incorrect 179 ms 4344 KB Unexpected end of file - int32 expected
12 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
13 Incorrect 2 ms 256 KB Unexpected end of file - int32 expected
14 Incorrect 2 ms 256 KB Unexpected end of file - int32 expected