답안 #1005941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005941 2024-06-23T08:35:27 Z thelegendary08 가장 긴 여행 (IOI23_longesttrip) C++17
5 / 100
832 ms 596 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[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

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]);
      |   ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 348 KB Output is correct
2 Correct 27 ms 348 KB Output is correct
3 Correct 158 ms 348 KB Output is correct
4 Correct 405 ms 424 KB Output is correct
5 Correct 808 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 344 KB Output is correct
2 Correct 25 ms 344 KB Output is correct
3 Correct 136 ms 348 KB Output is correct
4 Correct 410 ms 348 KB Output is correct
5 Correct 802 ms 352 KB Output is correct
6 Incorrect 1 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 23 ms 344 KB Output is correct
3 Correct 161 ms 344 KB Output is correct
4 Correct 410 ms 420 KB Output is correct
5 Correct 806 ms 596 KB Output is correct
6 Incorrect 0 ms 348 KB Incorrect
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 348 KB Output is correct
2 Correct 30 ms 352 KB Output is correct
3 Partially correct 165 ms 356 KB Output is partially correct
4 Partially correct 410 ms 428 KB Output is partially correct
5 Partially correct 832 ms 344 KB Output is partially correct
6 Incorrect 1 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -