Submission #1005946

#TimeUsernameProblemLanguageResultExecution timeMemory
1005946thelegendary08Longest Trip (IOI23_longesttrip)C++17
15 / 100
875 ms596 KiB
#include "longesttrip.h" #include<bits/stdc++.h> #define f0r(i,n) for(int i = 0;i<n;i++) #define FOR(i,k,n) for(int i = k;i<n;i++) #define pb push_back #define vi vector<int> #define ll long long int using namespace std; std::vector<int> longest_trip(int N, int D) { vector<vector<bool>> con(N, vector<bool>(N, false)); f0r(i, N){ FOR(j, i+1, N){ con[i][j] = are_connected({i}, {j}); con[j][i] = con[i][j]; } } vi c1 = {0}; vi c2 = {1}; FOR(i, 2, N){ if(con[c1[c1.size()-1]][i])c1.pb(i); else c2.pb(i); } if(c1.size() == 1)swap(c1, c2); vi ans; if(con[c1[0]][c2[0]]){ for(int i = c2.size() - 1; i>=0; i--)ans.pb(c2[i]); f0r(i, c1.size())ans.pb(c1[i]); } else{ f0r(i,c1.size())ans.pb(c1[i]); f0r(i, c2.size())ans.pb(c2[i]); } return ans; }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:4:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define f0r(i,n) for(int i = 0;i<n;i++)
......
   30 |   f0r(i, c1.size())ans.pb(c1[i]);
      |       ~~~~~~~~~~~~               
longesttrip.cpp:30:3: note: in expansion of macro 'f0r'
   30 |   f0r(i, c1.size())ans.pb(c1[i]);
      |   ^~~
longesttrip.cpp:4:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define f0r(i,n) for(int i = 0;i<n;i++)
......
   33 |   f0r(i,c1.size())ans.pb(c1[i]);
      |       ~~~~~~~~~~~                
longesttrip.cpp:33:3: note: in expansion of macro 'f0r'
   33 |   f0r(i,c1.size())ans.pb(c1[i]);
      |   ^~~
longesttrip.cpp:4:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define f0r(i,n) for(int i = 0;i<n;i++)
......
   34 |   f0r(i, c2.size())ans.pb(c2[i]);
      |       ~~~~~~~~~~~~               
longesttrip.cpp:34:3: note: in expansion of macro 'f0r'
   34 |   f0r(i, c2.size())ans.pb(c2[i]);
      |   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...