제출 #432453

#제출 시각아이디문제언어결과실행 시간메모리
432453A_D비스킷 담기 (IOI20_biscuits)C++14
0 / 100
1084 ms18524 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;
LL ret=0,y,sz;
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(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){
    a.clear();
    c.clear();
    vec.clear();
    st.clear();
    vector<int> 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);
    for(int i=0;i<b.size();i++){
        a[i]=b[i];
    }
    vec.resize(maxsz);
    bc(0);
    return st.size();
}

컴파일 시 표준 에러 (stderr) 메시지

biscuits.cpp: In function 'bool ok()':
biscuits.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i=1;i<vec.size();i++){
      |                 ~^~~~~~~~~~~
biscuits.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i=1;i<c.size();i++){
      |                 ~^~~~~~~~~
biscuits.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i=0;i<vec2.size();i++){
      |                 ~^~~~~~~~~~~~
biscuits.cpp: In function 'void ad()':
biscuits.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     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:73:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     for(int i=0;i<b.size();i++){
      |                 ~^~~~~~~~~
biscuits.cpp:76:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |     for(int i=1;i<d.size();i++){
      |                 ~^~~~~~~~~
biscuits.cpp:87:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |     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...