Submission #290248

#TimeUsernameProblemLanguageResultExecution timeMemory
290248beso123Fun Tour (APIO20_fun)C++14
Compilation error
0 ms0 KiB
#include "fun.h" #include <bits/stdc++.h> using namespace std; 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:4:25: error: 'pii' was not declared in this scope
    4 | vector<int> get_pas(set<pii> s1,set<pii> s2){
      |                         ^~~
fun.cpp:4:28: error: template argument 1 is invalid
    4 | vector<int> get_pas(set<pii> s1,set<pii> s2){
      |                            ^
fun.cpp:4:28: error: template argument 2 is invalid
fun.cpp:4:28: error: template argument 3 is invalid
fun.cpp:4:37: error: 'pii' was not declared in this scope
    4 | vector<int> get_pas(set<pii> s1,set<pii> s2){
      |                                     ^~~
fun.cpp:4:40: error: template argument 1 is invalid
    4 | vector<int> get_pas(set<pii> s1,set<pii> s2){
      |                                        ^
fun.cpp:4:40: error: template argument 2 is invalid
fun.cpp:4:40: error: template argument 3 is invalid
fun.cpp: In function 'std::vector<int> get_pas(int, int)':
fun.cpp:7:7: error: request for member 'size' in 's2', which is of non-class type 'int'
    7 | if(s2.size()>s1.size())
      |       ^~~~
fun.cpp:7:17: error: request for member 'size' in 's1', which is of non-class type 'int'
    7 | if(s2.size()>s1.size())
      |                 ^~~~
fun.cpp:10:9: error: 'pii' was not declared in this scope
   10 |         pii v;
      |         ^~~
fun.cpp:12:9: error: 'v' was not declared in this scope
   12 |         v=*s1.begin();
      |         ^
fun.cpp:12:15: error: request for member 'begin' in 's1', which is of non-class type 'int'
   12 |         v=*s1.begin();
      |               ^~~~~
fun.cpp:13:12: error: request for member 'erase' in 's1', which is of non-class type 'int'
   13 |         s1.erase(s1.begin());
      |            ^~~~~
fun.cpp:13:21: error: request for member 'begin' in 's1', which is of non-class type 'int'
   13 |         s1.erase(s1.begin());
      |                     ^~~~~
fun.cpp:17:16: error: 'v' was not declared in this scope
   17 |                v=*s2.begin();
      |                ^
fun.cpp:17:22: error: request for member 'begin' in 's2', which is of non-class type 'int'
   17 |                v=*s2.begin();
      |                      ^~~~~
fun.cpp:18:12: error: request for member 'erase' in 's2', which is of non-class type 'int'
   18 |         s2.erase(s2.begin());
      |            ^~~~~
fun.cpp:18:21: error: request for member 'begin' in 's2', which is of non-class type 'int'
   18 |         s2.erase(s2.begin());
      |                     ^~~~~
fun.cpp:22:11: error: request for member 'size' in 's1', which is of non-class type 'int'
   22 |     if(s1.size()==0 && s2.size()==0)
      |           ^~~~
fun.cpp:22:27: error: request for member 'size' in 's2', which is of non-class type 'int'
   22 |     if(s1.size()==0 && s2.size()==0)
      |                           ^~~~
fun.cpp: At global scope:
fun.cpp:27:16: error: 'pii' was not declared in this scope
   27 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                ^~~
fun.cpp:27:19: error: template argument 1 is invalid
   27 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                   ^
fun.cpp:27:19: error: template argument 2 is invalid
fun.cpp:27:19: error: template argument 3 is invalid
fun.cpp:27:28: error: 'pii' was not declared in this scope
   27 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                            ^~~
fun.cpp:27:31: error: template argument 1 is invalid
   27 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                               ^
fun.cpp:27:31: error: template argument 2 is invalid
fun.cpp:27:31: error: template argument 3 is invalid
fun.cpp:27:40: error: 'pii' was not declared in this scope
   27 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                                        ^~~
fun.cpp:27:43: error: template argument 1 is invalid
   27 | bool check(set<pii> s1,set<pii> s2,set<pii> s3){
      |                                           ^
fun.cpp:27:43: error: template argument 2 is invalid
fun.cpp:27:43: error: template argument 3 is invalid
fun.cpp: In function 'bool check(int, int, int)':
fun.cpp:28:16: error: request for member 'size' in 's1', which is of non-class type 'int'
   28 |     if((int)s1.size()+(int)s2.size()==s3.size())
      |                ^~~~
fun.cpp:28:31: error: request for member 'size' in 's2', which is of non-class type 'int'
   28 |     if((int)s1.size()+(int)s2.size()==s3.size())
      |                               ^~~~
fun.cpp:28:42: error: request for member 'size' in 's3', which is of non-class type 'int'
   28 |     if((int)s1.size()+(int)s2.size()==s3.size())
      |                                          ^~~~
fun.cpp: At global scope:
fun.cpp:32:21: error: 'pii' was not declared in this scope
   32 | vector<int> off(set<pii> s1,set<pii> s2,set<pii> s3,int d){
      |                     ^~~
fun.cpp:32:24: error: template argument 1 is invalid
   32 | vector<int> off(set<pii> s1,set<pii> s2,set<pii> s3,int d){
      |                        ^
fun.cpp:32:24: error: template argument 2 is invalid
fun.cpp:32:24: error: template argument 3 is invalid
fun.cpp:32:33: error: 'pii' was not declared in this scope
   32 | vector<int> off(set<pii> s1,set<pii> s2,set<pii> s3,int d){
      |                                 ^~~
fun.cpp:32:36: error: template argument 1 is invalid
   32 | vector<int> off(set<pii> s1,set<pii> s2,set<pii> s3,int d){
      |                                    ^
fun.cpp:32:36: error: template argument 2 is invalid
fun.cpp:32:36: error: template argument 3 is invalid
fun.cpp:32:45: error: 'pii' was not declared in this scope
   32 | vector<int> off(set<pii> s1,set<pii> s2,set<pii> s3,int d){
      |                                             ^~~
fun.cpp:32:48: error: template argument 1 is invalid
   32 | vector<int> off(set<pii> s1,set<pii> s2,set<pii> s3,int d){
      |                                                ^
fun.cpp:32:48: error: template argument 2 is invalid
fun.cpp:32:48: error: template argument 3 is invalid
fun.cpp: In function 'std::vector<int> off(int, int, int, int)':
fun.cpp:33:8: error: 'pii' was not declared in this scope
   33 |    set<pii>::iterator it;
      |        ^~~
fun.cpp:33:11: error: template argument 1 is invalid
   33 |    set<pii>::iterator it;
      |           ^
fun.cpp:33:11: error: template argument 2 is invalid
fun.cpp:33:11: error: template argument 3 is invalid
fun.cpp:33:23: error: expected initializer before 'it'
   33 |    set<pii>::iterator it;
      |                       ^~
fun.cpp:34:8: error: 'it' was not declared in this scope; did you mean 'int'?
   34 |    for(it=s2.begin();it!=s2.end();it++){
      |        ^~
      |        int
fun.cpp:34:14: error: request for member 'begin' in 's2', which is of non-class type 'int'
   34 |    for(it=s2.begin();it!=s2.end();it++){
      |              ^~~~~
fun.cpp:34:29: error: request for member 'end' in 's2', which is of non-class type 'int'
   34 |    for(it=s2.begin();it!=s2.end();it++){
      |                             ^~~
fun.cpp:35:8: error: request for member 'insert' in 's1', which is of non-class type 'int'
   35 |     s1.insert(*it);
      |        ^~~~~~
fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:65:5: error: 'pii' was not declared in this scope
   65 | set<pii> s1,s2,s3;
      |     ^~~
fun.cpp:65:8: error: template argument 1 is invalid
   65 | set<pii> s1,s2,s3;
      |        ^
fun.cpp:65:8: error: template argument 2 is invalid
fun.cpp:65:8: error: template argument 3 is invalid
fun.cpp:66:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 | for(int k=0;k<al.size();k++){
      |             ~^~~~~~~~~~
fun.cpp:71:12: error: request for member 'insert' in 's1', which is of non-class type 'int'
   71 |         s1.insert({-dist[a],a});
      |            ^~~~~~
fun.cpp:74:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 | for(int k=0;k<al.size();k++){
      |             ~^~~~~~~~~~
fun.cpp:80:12: error: request for member 'insert' in 's2', which is of non-class type 'int'
   80 |         s2.insert({-dist[a],a});
      |            ^~~~~~
fun.cpp:84:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |    for(int k=0;k<al.size();k++){
      |                ~^~~~~~~~~~
fun.cpp:88:8: error: request for member 'insert' in 's3', which is of non-class type 'int'
   88 |     s3.insert({-dist[a],a});
      |        ^~~~~~
fun.cpp:91:8: error: template argument 2 is invalid
   91 | set<pii>::iterator it;
      |        ^
fun.cpp:91:8: error: template argument 3 is invalid
fun.cpp:91:20: error: expected initializer before 'it'
   91 | set<pii>::iterator it;
      |                    ^~
fun.cpp:122:8: error: expected ';' before 'v1'
  122 |     pii v1=*s1.begin(),v2=*s2.begin(),v3=*s3.begin();
      |        ^~~
      |        ;
fun.cpp:124:9: error: 'v1' was not declared in this scope; did you mean 's1'?
  124 |         v1.x=1;
      |         ^~
      |         s1
fun.cpp:126:9: error: 'v2' was not declared in this scope; did you mean 's2'?
  126 |         v2.x=1;
      |         ^~
      |         s2
fun.cpp:128:9: error: 'v3' was not declared in this scope; did you mean 's3'?
  128 |         v3.x=1;
      |         ^~
      |         s3
fun.cpp:129:16: error: 'v1' was not declared in this scope; did you mean 's1'?
  129 |     int mn=min(v1.x,min(v2.x,v3.x));
      |                ^~
      |                s1
fun.cpp:129:25: error: 'v2' was not declared in this scope; did you mean 's2'?
  129 |     int mn=min(v1.x,min(v2.x,v3.x));
      |                         ^~
      |                         s2
fun.cpp:129:30: error: 'v3' was not declared in this scope; did you mean 's3'?
  129 |     int mn=min(v1.x,min(v2.x,v3.x));
      |                              ^~
      |                              s3
fun.cpp:133:12: error: request for member 'erase' in 's1', which is of non-class type 'int'
  133 |         s1.erase(s1.begin());
      |            ^~~~~
fun.cpp:133:21: error: request for member 'begin' in 's1', which is of non-class type 'int'
  133 |         s1.erase(s1.begin());
      |                     ^~~~~
fun.cpp:139:12: error: request for member 'erase' in 's2', which is of non-class type 'int'
  139 |         s2.erase(s2.begin());
      |            ^~~~~
fun.cpp:139:21: error: request for member 'begin' in 's2', which is of non-class type 'int'
  139 |         s2.erase(s2.begin());
      |                     ^~~~~
fun.cpp:145:12: error: request for member 'erase' in 's3', which is of non-class type 'int'
  145 |         s3.erase(s3.begin());
      |            ^~~~~
fun.cpp:145:21: error: request for member 'begin' in 's3', which is of non-class type 'int'
  145 |         s3.erase(s3.begin());
      |                     ^~~~~
fun.cpp:150:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  150 | for(int k=0;k<p.size();k++)
      |             ~^~~~~~~~~