답안 #991662

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
991662 2024-06-02T18:27:38 Z De3b0o Present (RMI21_present) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)

using namespace std;

ll fp(ll x , ll y)
{
    if(y==0)
        return 1;
    ll z = fp(x,y/2);
    if(y&1)
        return z*z*x;
    else
        return z*z;
}

int sqrot(ll x)
{
    int l = 0 , r = INT_MAX;
    while(l<=r)
    {
        if(mid*mid>=x)
            r=mid-1;
        else
            l=mid+1;
    }
    return r+1;
}

ll cel(ll x , ll y)
{
    return x/y + bool(x%y);
}

string tb(ll x)
{
    string s = "";
    while(x>0)
    {
        if(x&1)
            s+='1';
        else
            s+='0';
        x/=2;
    }
    while(s.size()<60)
        s+='0';
    return s;
}

ll fb(string s)
{
    ll x = 0;
    ll c = 1;
    for(int8_t i = 0 ; 60>i ; i++)
    {
        if(s[i]=='1')
            x+=c;
        c*=2;
    }
    return x;
}

set<vector<ll>> s;
ll gcd[9][9];
bool cnt[9];
vector<vector<ll>> ans;

void solve(ll idx , vector<ll> e , ll mx)
{
    if(idx==8)
    {
        bool g=1;
        memset(cnt,0,sizeof(cnt));
        for(auto it : e)
            cnt[it]=1;
        for(int i = 0 ; e.size()>i ; i++)
        {
            for(int j = i+1 ; e.size()>j ; j++)
            {
                if(cnt[gcd[e[i]][e[j]]]==0)
                    g=0;
            }
        }
        reverse(e.begin(),e.end());
        if(g)
            s.in(e);
        return;
    }
    vector<ll> e2=e;
    solve(idx+1,e2,mx);
    for(int i = mx+1 ; 8>=i ; i++)
    {
        vector<ll> e1 = e;
        e1.pb(i);
        solve(idx+1,e1,i);
    }
}

int main()
{
    d3
    ll t;
    cin >> t;
    for(int i = 1 ; 8>=i ; i++)
    {
        for(int j = 1 ; 8>=j ; j++)
            gcd[i][j]=__gcd(i,j);
    }
    solve(0,{},0);
    vector<vector<ll>> v;
    for(auto it : s)
        v.pb(it);
    sort(v.begin(),v.end());
    for(auto it : v)
        ans.pb(it);
    while(t--)
    {
        ll k;
        cin >> k;
        cout << ans[k].size() << " ";
        for(int i = ans[k].size()-1 ; i>=0 ; i--)
            cout << ans[k][i] << " ";
        lin
    }
}

Compilation message

Main.cpp: In function 'void solve(long long int, std::vector<long long int>, long long int)':
Main.cpp:93:33: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   93 |         for(int i = 0 ; e.size()>i ; i++)
      |                         ~~~~~~~~^~
Main.cpp:95:39: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   95 |             for(int j = i+1 ; e.size()>j ; j++)
      |                               ~~~~~~~~^~
Main.cpp:97:24: error: reference to 'gcd' is ambiguous
   97 |                 if(cnt[gcd[e[i]][e[j]]]==0)
      |                        ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from Main.cpp:1:
/usr/include/c++/10/numeric:131:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  131 |     gcd(_Mn __m, _Nn __n)
      |     ^~~
Main.cpp:81:4: note:                 'long long int gcd [9][9]'
   81 | ll gcd[9][9];
      |    ^~~
Main.cpp: In function 'int main()':
Main.cpp:124:13: error: reference to 'gcd' is ambiguous
  124 |             gcd[i][j]=__gcd(i,j);
      |             ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from Main.cpp:1:
/usr/include/c++/10/numeric:131:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  131 |     gcd(_Mn __m, _Nn __n)
      |     ^~~
Main.cpp:81:4: note:                 'long long int gcd [9][9]'
   81 | ll gcd[9][9];
      |    ^~~