Submission #315558

# Submission time Handle Problem Language Result Execution time Memory
315558 2020-10-23T04:57:45 Z daniel920712 Costinland (info1cup19_costinland) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <map>

using namespace std;
long long con[205][205]={0};
vector < pair < long long , long long > > all;
vector < char > ans[205];
//priority_queue < pair < long long , pair < long long , long long > > ,vector < pair < long long , pair < long long , long long > > >, less < pair < long long , pair < long long , long long > > > > how;
map < long long , pair < long long , long long > > how;
int main()
{
    long long i,j,N=0,M=0,now=0,n,last;
    scanf("%lld",&n);
    con[1][1]=1;
    if(n<=19)
    {
        for(i=1;i<=4;i++)
        {
            for(j=1;j<=4;j++)
            {
                if(i>1&&con[i-1][j]>=0) con[i][j]+=con[i-1][j];
                else if(i>1) con[i][j]=-1e18;
                if(j>1&&con[i][j-1]>=0) con[i][j]+=con[i][j-1];
                else if(j>1) con[i][j]=-1e18;
                if(con[i][j]>n) con[i][j]=-1e18;
                else
                {
                    if(how.find(con[i][j])==how.end()) how[con[i][j]]=make_pair(i,j);
                    else if(j<how[con[i][j]].second) how[con[i][j]]=make_pair(i,j);
                }

            }
        }
    }
    else
    {
        for(i=1;i<=100;i++)
        {
            for(j=1;j<=100;j++)
            {
                if(i>1&&con[i-1][j]>=0) con[i][j]+=con[i-1][j];
                else if(i>1) con[i][j]=-1e18;
                if(j>1&&con[i][j-1]>=0) con[i][j]+=con[i][j-1];
                else if(j>1) con[i][j]=-1e18;
                if(con[i][j]>n) con[i][j]=-1e18;
                else
                {
                    if(how.find(con[i][j])==how.end()) how[con[i][j]]=make_pair(i,j);
                    else if(j<how[con[i][j]].second) how[con[i][j]]=make_pair(i,j);
                }
            }
        }
    }

    while(n)
    {
        //printf("%lld\n",n);
        while(n<prev(how.end())->first) how.erase(prev(how.end()));
        all.push_back(prev(how.end())->second);
        n-=prev(how.end())->first;
        N=max(N,prev(how.end())->second.first);
        M+=prev(how.end())->second.second;
    }
    //printf("%lld %lld\n",N,M);
    N=max(N,62);
    for(i=0;i<=N;i++)
    {
        for(j=0;j<M;j++) ans[i].push_back('X');


    }
    for(j=0;j<M;j++) ans[0][j]='r';

    for(auto i:all)
    {
        //printf("%lld %lld\n",i.first,i.second);
        ans[0][now]='X';
        last=now;
        for(j=1;j<=N;j++) ans[j][now+i.second-1]='d';
        for(j=1;j<=N-i.first;j++) ans[j][now]='d';
        now+=i.second;
    }
    ans[0][last]='d';
    for(i=0;i<N;i++) ans[i][M-1]='d';
    for(i=0;i<M;i++) ans[N][i]='r';
    ans[N][M-1]='.';
    printf("%lld %lld\n",N+1,M);
    for(i=0;i<=N;i++)
    {
        for(j=0;j<M;j++) printf("%c",ans[i][j]);
        printf("\n");
    }

    return 0;
}

Compilation message

costinland.cpp: In function 'int main()':
costinland.cpp:69:15: error: no matching function for call to 'max(long long int&, int)'
   69 |     N=max(N,62);
      |               ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from costinland.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
costinland.cpp:69:15: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   69 |     N=max(N,62);
      |               ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from costinland.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
costinland.cpp:69:15: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   69 |     N=max(N,62);
      |               ^
costinland.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~