Submission #432456

#TimeUsernameProblemLanguageResultExecution timeMemory
432456A_D비스킷 담기 (IOI20_biscuits)C++14
0 / 100
1095 ms1904 KiB
#include "biscuits.h"
#include <bits/stdc++.h>
#define LL long long
using namespace std;
vector<LL> a;
vector<LL> c;
vector<LL> vec;
set<vector<LL>> st;
map<vector<LL>,bool>mp;
LL ret=0,y,sz;
vector<LL> com(vector<LL> vec)
{
    vector<LL> vec2=vec;
    for(int i=1;i<vec2.size();i++){
        while(vec2[i-1]>1){
            vec2[i-1]-=2;
            vec2[i]++;
        }
    }
    return vec2;
}
inline void add(int u)
{
    vec[u]++;
}
inline void rem(int u)
{
    vec[u]--;
}
bool ok()
{
    vector<LL> vec2=vec;
    for(int i=1;i<vec.size();i++){
        while(vec2[i-1]>1){
            vec2[i-1]-=2;
            vec2[i]++;
        }
    }
    c=a;
    for(int i=1;i<c.size();i++){
        while(c[i-1]>vec2[i-1]*y+1){
            c[i-1]-=2;
            c[i]++;
        }
    }
    for(int i=0;i<vec2.size();i++){
        if(c[i]<vec2[i]*y)return 0;
    }
    return 1;
}
void ad()
{
    vector<LL> vec2=vec;
    for(int i=1;i<vec.size();i++){
        while(vec2[i-1]>1){
            vec2[i-1]-=2;
            vec2[i]++;
        }
    }
    st.insert(vec2);
}
void bc(int i)
{
    if(mp[com(vec)])return;
    mp[com(vec)]=1;
    if(i==sz){
        ad();
        return;
    }
    add(i);
    if(ok()){
        bc(i);
    }
    rem(i);
    bc(i+1);
}
long long count_tastiness(long long x,vector<long long> b){
    mp.clear();
    a.clear();
    c.clear();
    vec.clear();
    st.clear();
    vector<LL> d;
    sz=b.size();
    y=x;
    int maxsz;
    d.resize(b.size()*100);
    for(int i=0;i<b.size();i++){
        d[i]=b[i];
    }
    for(int i=1;i<d.size();i++){
        while(d[i-1]>1){
            d[i-1]-=2;
            d[i]++;
        }
    }
    while(d.back()==0){
        d.pop_back();
    }
    maxsz=d.size();
    a.resize(maxsz+3);
    for(int i=0;i<b.size();i++){
        a[i]=b[i];
    }
    vec.resize(maxsz+3);
    bc(0);
    /*
    for(auto x:st){
        for(auto y:x){
            cout<<y<<" ";
        }
        cout<<endl;
    }
    */
    return st.size();
}

Compilation message (stderr)

biscuits.cpp: In function 'std::vector<long long int> com(std::vector<long long int>)':
biscuits.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=1;i<vec2.size();i++){
      |                 ~^~~~~~~~~~~~
biscuits.cpp: In function 'bool ok()':
biscuits.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=1;i<vec.size();i++){
      |                 ~^~~~~~~~~~~
biscuits.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int i=1;i<c.size();i++){
      |                 ~^~~~~~~~~
biscuits.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i=0;i<vec2.size();i++){
      |                 ~^~~~~~~~~~~~
biscuits.cpp: In function 'void ad()':
biscuits.cpp:54:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for(int i=1;i<vec.size();i++){
      |                 ~^~~~~~~~~~~
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:88:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |     for(int i=0;i<b.size();i++){
      |                 ~^~~~~~~~~
biscuits.cpp:91:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |     for(int i=1;i<d.size();i++){
      |                 ~^~~~~~~~~
biscuits.cpp:102:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |     for(int i=0;i<b.size();i++){
      |                 ~^~~~~~~~~
#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...