답안 #414535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
414535 2021-05-30T15:30:16 Z medmdg MalnaRISC (COI21_malnarisc) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ll  long long
#define endl    "\n"
using namespace std;
void pr(pair<ll,ll> a){
    cout<<"CMPSWP R"<<a.first<<" R"<<a.second<<" ";
}
int main() {
    ll n;
    cin>>n;
    vector<vector<pair<ll,ll> > >ans;
    bool a[n][n]={{false}};
    for(int i=0;i<n;i++)
        a[i][i]=true;
    for(int f=0;f<n;f++){
        bool h[n]={false};
        if(f>0)
        if(ans[ans.size()-1].size()==0)
            break;
        ans.push_back(new vector<pair<ll,ll> >);
    for(int i=0;i<n;i++){
        if(h[i])
            continue;
        for(int j=0;j<n;j++){
            if(h[j])
                continue;
            if(a[i][j]==false){
                a[i][j]=true;
                h[i]=true;
                h[j]=true;
                a[j][i]=true;
                ans.push_back(make_pair(i+1,j+1));
                break;
            }
        }
    }
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
        for(int j=0;j<ans[i].size();j++){
            pr(ans[i][j]);
        }
        cout<<endl;
    }
}

Compilation message

malnarisc.cpp: In function 'int main()':
malnarisc.cpp:20:47: error: no matching function for call to 'std::vector<std::vector<std::pair<long long int, long long int> > >::push_back(std::vector<std::pair<long long int, long long int> >*)'
   20 |         ans.push_back(new vector<pair<ll,ll> >);
      |                                               ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from malnarisc.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<long long int, long long int> >]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::vector<std::pair<long long int, long long int> >*' to 'const value_type&' {aka 'const std::vector<std::pair<long long int, long long int> >&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<long long int, long long int> >]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::vector<std::pair<long long int, long long int> >*' to 'std::vector<std::vector<std::pair<long long int, long long int> > >::value_type&&' {aka 'std::vector<std::pair<long long int, long long int> >&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
malnarisc.cpp:32:49: error: no matching function for call to 'std::vector<std::vector<std::pair<long long int, long long int> > >::push_back(std::pair<int, int>)'
   32 |                 ans.push_back(make_pair(i+1,j+1));
      |                                                 ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from malnarisc.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<long long int, long long int> >]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const value_type&' {aka 'const std::vector<std::pair<long long int, long long int> >&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<long long int, long long int> >]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<std::vector<std::pair<long long int, long long int> > >::value_type&&' {aka 'std::vector<std::pair<long long int, long long int> >&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
malnarisc.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0;i<ans.size();i++){
      |                 ~^~~~~~~~~~~
malnarisc.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int j=0;j<ans[i].size();j++){
      |                     ~^~~~~~~~~~~~~~