Submission #1005937

# Submission time Handle Problem Language Result Execution time Memory
1005937 2024-06-23T08:25:58 Z thelegendary08 Longest Trip (IOI23_longesttrip) C++17
5 / 100
843 ms 592 KB
#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});
		}
	}
	vi c1 = {0};
	vi c2 = {1};
	FOR(i, 2, N){
		if(con[0][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

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++)
......
   29 |   f0r(i, c1.size())ans.pb(c1[i]);
      |       ~~~~~~~~~~~~               
longesttrip.cpp:29:3: note: in expansion of macro 'f0r'
   29 |   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++)
......
   32 |   f0r(i,c1.size())ans.pb(c1[i]);
      |       ~~~~~~~~~~~                
longesttrip.cpp:32:3: note: in expansion of macro 'f0r'
   32 |   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, c2.size())ans.pb(c2[i]);
      |       ~~~~~~~~~~~~               
longesttrip.cpp:33:3: note: in expansion of macro 'f0r'
   33 |   f0r(i, c2.size())ans.pb(c2[i]);
      |   ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 22 ms 356 KB Output is correct
3 Correct 145 ms 348 KB Output is correct
4 Correct 390 ms 424 KB Output is correct
5 Correct 838 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Correct 144 ms 344 KB Output is correct
4 Correct 394 ms 592 KB Output is correct
5 Correct 805 ms 344 KB Output is correct
6 Incorrect 1 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 26 ms 344 KB Output is correct
3 Correct 140 ms 344 KB Output is correct
4 Correct 423 ms 436 KB Output is correct
5 Correct 810 ms 344 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 28 ms 344 KB Output is correct
3 Partially correct 133 ms 344 KB Output is partially correct
4 Partially correct 385 ms 592 KB Output is partially correct
5 Partially correct 843 ms 340 KB Output is partially correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -