Submission #238654

#TimeUsernameProblemLanguageResultExecution timeMemory
238654Ruxandra985곤돌라 (IOI14_gondola)C++14
20 / 100
18 ms1536 KiB
#include <bits/stdc++.h>
#include "gondola.h"
using namespace std;

int f[100010];

int valid(int n, int v[]){

    int i , found , poz , ok , pin , fi , space;
    found = -1;
    poz = 0;
    ok = 0;

    for (i = 0 ; i < n ; i++)
        v[i]--;

    for (i = 0 ; i < n ; i++){

        if (f[v[i]])
            return 0;

        f[v[i]] = 1;

        if (v[i] < n){

            if (found == -1){
                found = v[i];
                poz = i;
                pin = i;
                fi = v[i];
            }
            else {
                if (found > v[i]){

                    if (ok == 1)
                        return 0;
                    ok = 1;

                    space = n - 1 - found + v[i];

                    if (space != i - poz - 1)
                        return 0;

                    found = v[i];
                    poz = i;

                }
                else {

                    space = v[i] - found - 1;

                    if (space != i - poz - 1)
                        return 0;




                    found = v[i];
                    poz = i;
                }
            }

        }


    }

    /// verif cu ult poz si prima poz

    if (found == -1)
        return 1;


    if (found > fi){

        if (ok == 1)
            return 0;
        ok = 1;

        space = n - 1 - found + fi;

        if (space != (n - 1) - poz + pin)
            return 0;


    }
    else {

        if (!ok)
            return 0;

        space = fi - found - 1;

        if (space != (n - 1) - poz + pin)
            return 0;

    }


    return 1;
}

//----------------------

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  return -2;
}

//----------------------

int countReplacement(int n, int inputSeq[])
{
  return -3;
}

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:80:15: warning: 'fi' may be used uninitialized in this function [-Wmaybe-uninitialized]
         space = n - 1 - found + fi;
         ~~~~~~^~~~~~~~~~~~~~~~~~~~
gondola.cpp:94:36: warning: 'pin' may be used uninitialized in this function [-Wmaybe-uninitialized]
         if (space != (n - 1) - poz + pin)
                      ~~~~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...