Submission #209831

# Submission time Handle Problem Language Result Execution time Memory
209831 2020-03-15T16:27:37 Z nicolaalexandra Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
325 ms 6436 KB
#include <bits/stdc++.h>
#define DIM 1000010
using namespace std;
int v[DIM];
int n,i,poz,sol,idx,k,sol_poz;
/*void solve (int val){
    if (val == 1 || sol)
        return;

    if (v[idx] == val-1){
        /// inseamna ca in stanga nu ma mai duc deloc
        idx++;
    } else {
        /// pot sa ma duc
        if (v[idx] > val-1){
            sol = val-1, poz = idx-1;
            return;
        }
        solve (val-1);
    }

    /// acum dreapta
    if (v[idx] == val-1)
        idx++;
    else {
        if (v[idx] > val-1){
            sol = val-1, poz = idx-1;
            return;
        }
        solve (val-1);
    }
}*/

int solve (int val, int idx){

    if (v[idx] == val) /// nu mai pot sa ma duc in stanga ca am deja valoarea
        return idx + 1;

    if (!val)
        return 0;

    /// stanga
    val--;
    int poz = solve (val,idx);

    if (v[poz] > val || v[poz] == 0){
        /// sunt obligata sa pun aici val
        sol = val;
        sol_poz = poz-1;

        return poz;
    }

    /// dreapta
    return solve (val,poz);
}

int main (){

   // ifstream cin ("zalmoxis.in");
   // ofstream cout ("zalmoxis.out");

    cin>>n>>k;
    for (i=1;i<=n;i++)
        cin>>v[i];

    //idx = 1;
    solve (30,1);

    for (i=1;i<=n;i++){
        cout<<v[i]<<" ";
        if (i == sol_poz)
            cout<<sol<<" ";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 290 ms 6392 KB not a zalsequence
2 Incorrect 325 ms 6392 KB not a zalsequence
3 Incorrect 303 ms 6392 KB not a zalsequence
4 Incorrect 293 ms 6436 KB not a zalsequence
5 Incorrect 287 ms 6392 KB not a zalsequence
6 Incorrect 299 ms 6268 KB not a zalsequence
# Verdict Execution time Memory Grader output
1 Incorrect 304 ms 6392 KB Unexpected end of file - int32 expected
2 Incorrect 299 ms 6264 KB Unexpected end of file - int32 expected
3 Incorrect 290 ms 6396 KB Unexpected end of file - int32 expected
4 Incorrect 299 ms 6264 KB Unexpected end of file - int32 expected
5 Incorrect 292 ms 6392 KB Unexpected end of file - int32 expected
6 Incorrect 297 ms 6264 KB Unexpected end of file - int32 expected
7 Incorrect 299 ms 6396 KB Unexpected end of file - int32 expected
8 Incorrect 299 ms 6392 KB Unexpected end of file - int32 expected
9 Incorrect 232 ms 5112 KB Unexpected end of file - int32 expected
10 Incorrect 93 ms 2168 KB Unexpected end of file - int32 expected
11 Incorrect 150 ms 3320 KB Unexpected end of file - int32 expected
12 Incorrect 5 ms 256 KB Unexpected end of file - int32 expected
13 Incorrect 5 ms 256 KB Unexpected end of file - int32 expected
14 Incorrect 5 ms 256 KB Unexpected end of file - int32 expected