Submission #1069577

#TimeUsernameProblemLanguageResultExecution timeMemory
1069577Faisal_SaqibLongest Trip (IOI23_longesttrip)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define ppll pair<ll,pll> #define vpl vector<pll> bool are_connected(std::vector<int> A, std::vector<int> B); std::vector<int> longest_trip(int n, int D) { if(D==3) { vector<int> ans; for(int i=0;i<n;i++) ans.push_back(i); return ans; } else if(D==2) { vector<int> ans; for(int i=n-1;i>0;i--) ans.pb(i); ll s=0; vll order={0}; while(ans.size()>1) { ll f1=ans.back(); ans.pop_back(); ll f2=ans.back(); ans.pop_back(); bool r1=are_connected({s},{f1}); bool r2=are_connected({s},{f2}); bool r3=are_connected({f1},{f2}); if(r1 and r3) { order.pb(f1); order.pb(f2); } else if(r2 and r3) { order.pb(f2); order.pb(f1); } s=order.back(); } if(ans.size()>0) { ll l=ans.back(); bool r1=are_connected({s},{l}); if(r1) order.pb(l); } return order; } }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:22:8: error: 'class std::vector<int>' has no member named 'pb'
   22 |    ans.pb(i);
      |        ^~
longesttrip.cpp:24:3: error: 'vll' was not declared in this scope; did you mean 'vpl'?
   24 |   vll order={0};
      |   ^~~
      |   vpl
longesttrip.cpp:31:27: warning: narrowing conversion of 's' from 'long long int' to 'int' [-Wnarrowing]
   31 |    bool r1=are_connected({s},{f1});
      |                           ^
longesttrip.cpp:31:27: warning: narrowing conversion of 's' from 'long long int' to 'int' [-Wnarrowing]
longesttrip.cpp:31:31: warning: narrowing conversion of 'f1' from 'long long int' to 'int' [-Wnarrowing]
   31 |    bool r1=are_connected({s},{f1});
      |                               ^~
longesttrip.cpp:31:31: warning: narrowing conversion of 'f1' from 'long long int' to 'int' [-Wnarrowing]
longesttrip.cpp:32:27: warning: narrowing conversion of 's' from 'long long int' to 'int' [-Wnarrowing]
   32 |    bool r2=are_connected({s},{f2});
      |                           ^
longesttrip.cpp:32:27: warning: narrowing conversion of 's' from 'long long int' to 'int' [-Wnarrowing]
longesttrip.cpp:32:31: warning: narrowing conversion of 'f2' from 'long long int' to 'int' [-Wnarrowing]
   32 |    bool r2=are_connected({s},{f2});
      |                               ^~
longesttrip.cpp:32:31: warning: narrowing conversion of 'f2' from 'long long int' to 'int' [-Wnarrowing]
longesttrip.cpp:33:27: warning: narrowing conversion of 'f1' from 'long long int' to 'int' [-Wnarrowing]
   33 |    bool r3=are_connected({f1},{f2});
      |                           ^~
longesttrip.cpp:33:27: warning: narrowing conversion of 'f1' from 'long long int' to 'int' [-Wnarrowing]
longesttrip.cpp:33:32: warning: narrowing conversion of 'f2' from 'long long int' to 'int' [-Wnarrowing]
   33 |    bool r3=are_connected({f1},{f2});
      |                                ^~
longesttrip.cpp:33:32: warning: narrowing conversion of 'f2' from 'long long int' to 'int' [-Wnarrowing]
longesttrip.cpp:36:5: error: 'order' was not declared in this scope
   36 |     order.pb(f1);
      |     ^~~~~
longesttrip.cpp:41:5: error: 'order' was not declared in this scope
   41 |     order.pb(f2);
      |     ^~~~~
longesttrip.cpp:44:6: error: 'order' was not declared in this scope
   44 |    s=order.back();
      |      ^~~~~
longesttrip.cpp:49:27: warning: narrowing conversion of 's' from 'long long int' to 'int' [-Wnarrowing]
   49 |    bool r1=are_connected({s},{l});
      |                           ^
longesttrip.cpp:49:27: warning: narrowing conversion of 's' from 'long long int' to 'int' [-Wnarrowing]
longesttrip.cpp:49:31: warning: narrowing conversion of 'l' from 'long long int' to 'int' [-Wnarrowing]
   49 |    bool r1=are_connected({s},{l});
      |                               ^
longesttrip.cpp:49:31: warning: narrowing conversion of 'l' from 'long long int' to 'int' [-Wnarrowing]
longesttrip.cpp:51:5: error: 'order' was not declared in this scope
   51 |     order.pb(l);
      |     ^~~~~
longesttrip.cpp:53:10: error: 'order' was not declared in this scope
   53 |   return order;
      |          ^~~~~