QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#109128#6503. DFS Order 3snowy2002#Compile Error//C++141.8kb2023-05-27 15:17:192023-05-27 15:17:21

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-27 15:17:21]
  • 评测
  • [2023-05-27 15:17:19]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define time chrono::system_clock::now().time_since_epoch().count()
#include<ext/pb_ds/tree_policy.hpp>
#define clean(x) memset(x,0,sizeof(x))
#define fil(x,n) fill(x,x+1+n,0)
#define inf 2000000009
#define maxn 1000005
// #define int long long
using namespace std;
using namespace __gnu_pbds;
mt19937_64 rnd(time);
cc_hash_table<int,int>mp;

int read() {
    int x=1,res=0;
    char c=getchar();
    while(c<'0'||c>'9') {
        if(c=='-') x=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9') {
        res=res*10+(c-'0');
        c=getchar();
    }
    return res*x;
}
set<pair<int,int>>s[1005];
int f[1005];

int fi(int x) {
    if(x!=f[x]) f[x]=fi(f[x]);
    return f[x];
}

void solve() {
    int n=read();
    vector id(n+1,vector(n+1,0ll));
    for(int i=1;i<=n;i++) s[i].clear();
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            int x=read();
            id[i][x]=j;
            s[i].insert({j,x});
        }
    }
    vector<pair<int,int>>ans;
    
    for(int i=1;i<=n;i++)  f[i]=i;
    while(s[1].size()>=2) {
        vector<int>res;
        for(int i=1;i<=n;i++) {
            auto u=*s[i].begin();
            auto v=*next(s[i].begin());
            if(fi(u.second)!=fi(v.second)) {
                ans.push_back({u.second,v.second});
                f[fi(u.second)]=fi(v.second);
            }
            auto z=s[i].rbegin()->second;
            res.push_back(z);
        }
        for(int i:res) {
            for(int j=1;j<=n;j++) {
                s[j].erase({id[j][i],i});
            }
        }
    }
    for(auto [u,v]:ans) {
        printf("%d %d\n",u,v);
    }
}

signed main()
{
    int t=read();
    while(t--) solve();
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:38:12: error: missing template arguments before ‘id’
   38 |     vector id(n+1,vector(n+1,0ll));
      |            ^~
answer.code:43:13: error: ‘id’ was not declared in this scope; did you mean ‘i’?
   43 |             id[i][x]=j;
      |             ^~
      |             i
answer.code:64:29: error: ‘id’ was not declared in this scope; did you mean ‘i’?
   64 |                 s[j].erase({id[j][i],i});
      |                             ^~
      |                             i
answer.code:64:27: error: no matching function for call to ‘std::set<std::pair<int, int> >::erase(<brace-enclosed initializer list>)’
   64 |                 s[j].erase({id[j][i],i});
      |                 ~~~~~~~~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:87,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_set.h:654:7: note: candidate: ‘std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator]’
  654 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/11/bits/stl_set.h:654:28: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘std::set<std::pair<int, int> >::const_iterator’ {aka ‘std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator’}
  654 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/11/bits/stl_set.h:684:7: note: candidate: ‘std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]’
  684 |       erase(const key_type& __x)
      |       ^~~~~
/usr/include/c++/11/bits/stl_set.h:684:29: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const key_type&’ {aka ‘const std::pair<int, int>&’}
  684 |       erase(const key_type& __x)
      |             ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_set.h:706:7: note: candidate: ‘std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::const_iterator) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator]’
  706 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/11/bits/stl_set.h:706:7: note:   candidate expects 2 arguments, 1 provided
answer.code:68:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’
   68 |     for(auto [u,v]:ans) {
      |              ^