Submission #272728

# Submission time Handle Problem Language Result Execution time Memory
272728 2020-08-18T14:14:11 Z shinjan Cave (IOI13_cave) C++14
46 / 100
18 ms 384 KB
#include <iostream>
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
int nadji(int tren,int s[],int d[],int n)
{
    int x;
    for(int i=0;i<n;i++)
    {
        if(d[i]<0)
        {
            s[i]=!s[i];
            x=tryCombination(s);
            if(x>tren)
            {
                d[i]=tren;
                return x;
            }
            if(x<tren)
            {
                d[i]=x;
                if(x==-1)
                {
                    return -1;
                }
                s[i]=!s[i];
            }

        }
    }
}
void exploreCave(int n)
{
    int s[n];
    int d[n];
    for(int i=0;i<n;i++)
    {
        s[i]=0;
        d[i]=-1;
    }
    int tren,prob,res;
    tren=tryCombination(s);
    int x;
    while(tren!=-1)
    {
        prob=tren;
        while(d[prob]>0)
        {
            prob=d[prob];
        }
        s[prob]=(!s[prob]);
        res=tryCombination(s);
        while(res<tren)
        {
            d[prob]=res;
            if(res==-1)
            {
                tren=-1;
                break;
            }
            s[prob]=(!s[prob]);
            prob=res;
            while(d[prob]>0)
            {
                prob=d[prob];
            }
            s[prob]=(!s[prob]);
            res=tryCombination(s);
        }
        if(res>tren && tren!=-1)
        {
            d[prob]=tren;
            tren=res;
        }
        else if(tren==res && tren!=-1)
        {
            tren=nadji(tren,s,d,n);
        }
    }
    for(int i=0;i<n;i++)
    {
        if(d[i]<0)
        {
            s[i]=(!s[i]);
            d[i]=tryCombination(s);
            s[i]=(!s[i]);
        }
    }
    answer(s,d);
}

Compilation message

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:43:9: warning: unused variable 'x' [-Wunused-variable]
   43 |     int x;
      |         ^
cave.cpp: In function 'int nadji(int, int*, int*, int)':
cave.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 10 ms 384 KB Output is correct
3 Correct 16 ms 384 KB Output is correct
4 Correct 11 ms 384 KB Output is correct
5 Correct 16 ms 384 KB Output is correct
6 Correct 15 ms 384 KB Output is correct
7 Correct 15 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 18 ms 384 KB Output is correct
13 Correct 18 ms 384 KB Output is correct
14 Correct 15 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 15 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 15 ms 384 KB Output is correct
7 Correct 14 ms 384 KB Output is correct
8 Correct 17 ms 384 KB Output is correct
9 Correct 17 ms 384 KB Output is correct
10 Correct 17 ms 384 KB Output is correct
11 Correct 15 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Incorrect 9 ms 384 KB too much calls on tryCombination()
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 10 ms 384 KB Output is correct
3 Correct 16 ms 384 KB Output is correct
4 Correct 11 ms 384 KB Output is correct
5 Correct 16 ms 384 KB Output is correct
6 Correct 15 ms 384 KB Output is correct
7 Correct 15 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 18 ms 384 KB Output is correct
13 Correct 18 ms 384 KB Output is correct
14 Correct 15 ms 384 KB Output is correct
15 Correct 15 ms 384 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 15 ms 384 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 15 ms 384 KB Output is correct
21 Correct 14 ms 384 KB Output is correct
22 Correct 17 ms 384 KB Output is correct
23 Correct 17 ms 384 KB Output is correct
24 Correct 17 ms 384 KB Output is correct
25 Correct 15 ms 384 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 0 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 256 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 1 ms 256 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 1 ms 384 KB Output is correct
40 Correct 1 ms 256 KB Output is correct
41 Correct 1 ms 384 KB Output is correct
42 Correct 0 ms 256 KB Output is correct
43 Correct 0 ms 256 KB Output is correct
44 Correct 1 ms 384 KB Output is correct
45 Incorrect 9 ms 384 KB too much calls on tryCombination()
46 Halted 0 ms 0 KB -