Submission #591517

# Submission time Handle Problem Language Result Execution time Memory
591517 2022-07-07T14:28:16 Z andrei_boaca Calvinball championship (CEOI15_teams) C++14
20 / 100
1000 ms 852 KB
#include <bits/stdc++.h>

using namespace std;
int nr=0;
vector<int> a;
vector<int> poz;
int v[10005];
int n;
void dfs()
{
    if(a.size()==n)
    {
        nr++;
        bool ok=1;
        for(int i=1;i<=n;i++)
            if(v[i]!=a[i-1])
                ok=0;
        if(ok)
        {
            cout<<nr;
            exit(0);
        }
        int val=a.back();
        if(a.size()==poz.back())
            poz.pop_back();
        a.pop_back();
        return;
    }
    int maxi=poz.size();
    for(int i=1;i<=maxi+1;i++)
    {
        a.push_back(i);
        if(i>maxi)
            poz.push_back(a.size());
        dfs();
    }
    if(!a.empty())
    {
        int val=a.back();
        if(a.size()==poz.back())
            poz.pop_back();
        a.pop_back();
    }
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    dfs();
    return 0;
}

Compilation message

teams.cpp: In function 'void dfs()':
teams.cpp:11:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   11 |     if(a.size()==n)
      |        ~~~~~~~~^~~
teams.cpp:24:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   24 |         if(a.size()==poz.back())
      |            ~~~~~~~~^~~~~~~~~~~~
teams.cpp:23:13: warning: unused variable 'val' [-Wunused-variable]
   23 |         int val=a.back();
      |             ^~~
teams.cpp:40:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   40 |         if(a.size()==poz.back())
      |            ~~~~~~~~^~~~~~~~~~~~
teams.cpp:39:13: warning: unused variable 'val' [-Wunused-variable]
   39 |         int val=a.back();
      |             ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 220 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 852 KB Time limit exceeded
2 Halted 0 ms 0 KB -