Submission #591498

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

using namespace std;
int nr=0;
vector<int> a;
multiset<int> s;
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();
        s.erase(s.find(val));
        a.pop_back();
        return;
    }
    int maxi=0;
    if(s.size())
        maxi=*prev(s.end());
    for(int i=1;i<=maxi+1;i++)
    {
        s.insert(i);
        a.push_back(i);
        dfs();
    }
    int val=a.back();
    s.erase(s.find(val));
    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)
      |        ~~~~~~~~^~~
# 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 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 1372 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 -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 1364 KB Time limit exceeded
2 Halted 0 ms 0 KB -