Submission #290245

#TimeUsernameProblemLanguageResultExecution timeMemory
290245beso123Fun Tour (APIO20_fun)C++14
Compilation error
0 ms0 KiB
#include "fun.h" #include <bits/stdc++.h> vector<int> get_pas(set<pii> s1,set<pii> s2){ vector<int> ans; int d=1; if(s2.size()>s1.size()) d=2; while(true){ pii v; if(d==1){ v=*s1.begin(); s1.erase(s1.begin()); ans.push_back(v.y); } else{ v=*s2.begin(); s2.erase(s2.begin()); ans.push_back(v.y); } d=3-d; if(s1.size()==0 && s2.size()==0) break; } return ans; } bool check(set<pii> s1,set<pii> s2,set<pii> s3){ if((int)s1.size()+(int)s2.size()==s3.size()) return true; return false; } vector<int> off(set<pii> s1,set<pii> s2,set<pii> s3,int d){ set<pii>::iterator it; for(it=s2.begin();it!=s2.end();it++){ s1.insert(*it); } if(d==-1) return get_pas(s3,s1); else return get_pas(s1,s3); } vector<int> createFunTour(int n,int Q1){ if(n==2){ return {0,1}; } int cnt=0,csize=INT_MAX; for(int k=1;k<n;k++){ int Size=attractionsBehind(0,k); if((Size-1)>=(n/2)){ if(Size<csize){ csize=Size; cnt=k; } } } vector<int> dist(n,0); vector<int> P,al; for(int k=0;k<n;k++){ if(k==cnt) continue; al.push_back(k); dist[k]=hoursRequired(k,cnt); if(dist[k]==1) P.push_back(k); } set<pii> s1,s2,s3; for(int k=0;k<al.size();k++){ int a=al[k]; if(dist[a]==hoursRequired(P[0],a)+1){ al[k]++; al[k]*=-1; s1.insert({-dist[a],a}); } } for(int k=0;k<al.size();k++){ if(al[k]<0) continue; int a=al[k]; if(dist[a]==hoursRequired(P[1],a)+1){ al[k]*=-1; s2.insert({-dist[a],a}); } } if(P.size()!=2){ for(int k=0;k<al.size();k++){ if(al[k]<0) continue; int a=al[k]; s3.insert({-dist[a],a}); } } set<pii>::iterator it; vector<int> ans; vector<int> p; if(P.size()==2){ ans=get_pas(s1,s2); } else{ int cur=0; while(true){ if(check(s1,s2,s3)){ int d=1; if(cur!=3) d=-1; p=off(s1,s2,s3,d); break; } if(check(s3,s2,s1)){ int d=1; if(cur!=1) d=-1; p=off(s3,s2,s1,d); break; } if(check(s1,s3,s2)){ int d=1; if(cur!=2) d=-1; p=off(s1,s3,s2,d); break; } pii v1=*s1.begin(),v2=*s2.begin(),v3=*s3.begin(); if(cur==1) v1.x=1; if(cur==2) v2.x=1; if(cur==3) v3.x=1; int mn=min(v1.x,min(v2.x,v3.x)); if(mn==v1.x){ ans.push_back(v1.y); cur=1; s1.erase(s1.begin()); } else if(mn==v2.x){ ans.push_back(v2.y); cur=2; s2.erase(s2.begin()); } else if(mn==v3.x){ ans.push_back(v3.y); cur=3; s3.erase(s3.begin()); } } } for(int k=0;k<p.size();k++) ans.push_back(p[k]); ans.push_back(cnt); return ans; }

Compilation message (stderr)

fun.cpp:3:1: error: 'vector' does not name a type
    3 | vector<int> get_pas(set<pii> s1,set<pii> s2){
      | ^~~~~~
fun.cpp:26:12: error: 'set' was not declared in this scope; did you mean 'std::set'?
   26 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |            ^~~
      |            std::set
In file included from /usr/include/c++/9/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:87,
                 from fun.cpp:2:
/usr/include/c++/9/bits/stl_set.h:94:11: note: 'std::set' declared here
   94 |     class set
      |           ^~~
fun.cpp:26:16: error: 'pii' was not declared in this scope
   26 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                ^~~
fun.cpp:26:21: error: 's1' was not declared in this scope; did you mean 'y1'?
   26 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                     ^~
      |                     y1
fun.cpp:26:24: error: 'set' was not declared in this scope; did you mean 'std::set'?
   26 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                        ^~~
      |                        std::set
In file included from /usr/include/c++/9/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:87,
                 from fun.cpp:2:
/usr/include/c++/9/bits/stl_set.h:94:11: note: 'std::set' declared here
   94 |     class set
      |           ^~~
fun.cpp:26:28: error: 'pii' was not declared in this scope
   26 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                            ^~~
fun.cpp:26:33: error: 's2' was not declared in this scope
   26 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                                 ^~
fun.cpp:26:36: error: 'set' was not declared in this scope; did you mean 'std::set'?
   26 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                                    ^~~
      |                                    std::set
In file included from /usr/include/c++/9/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:87,
                 from fun.cpp:2:
/usr/include/c++/9/bits/stl_set.h:94:11: note: 'std::set' declared here
   94 |     class set
      |           ^~~
fun.cpp:26:40: error: 'pii' was not declared in this scope
   26 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                                        ^~~
fun.cpp:26:45: error: 's3' was not declared in this scope
   26 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                                             ^~
fun.cpp:26:47: error: expression list treated as compound expression in initializer [-fpermissive]
   26 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                                               ^
fun.cpp:31:1: error: 'vector' does not name a type
   31 | vector<int> off(set<pii> s1,set<pii> s2,set<pii> s3,int d){
      | ^~~~~~
fun.cpp:40:1: error: 'vector' does not name a type
   40 | vector<int> createFunTour(int n,int Q1){
      | ^~~~~~