답안 #1005946

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005946 2024-06-23T08:42:40 Z thelegendary08 가장 긴 여행 (IOI23_longesttrip) C++17
15 / 100
875 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});
			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

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]);
      |   ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 27 ms 344 KB Output is correct
3 Correct 131 ms 344 KB Output is correct
4 Correct 365 ms 416 KB Output is correct
5 Correct 813 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 23 ms 344 KB Output is correct
3 Correct 148 ms 344 KB Output is correct
4 Correct 398 ms 424 KB Output is correct
5 Correct 875 ms 344 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 27 ms 344 KB Output is correct
8 Correct 150 ms 344 KB Output is correct
9 Correct 287 ms 344 KB Output is correct
10 Correct 833 ms 344 KB Output is correct
11 Correct 823 ms 344 KB Output is correct
12 Correct 832 ms 344 KB Output is correct
13 Correct 823 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 27 ms 344 KB Output is correct
3 Correct 156 ms 344 KB Output is correct
4 Correct 438 ms 432 KB Output is correct
5 Correct 806 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 19 ms 344 KB Output is correct
8 Correct 139 ms 344 KB Output is correct
9 Correct 325 ms 344 KB Output is correct
10 Correct 860 ms 344 KB Output is correct
11 Correct 819 ms 344 KB Output is correct
12 Correct 823 ms 344 KB Output is correct
13 Correct 859 ms 344 KB Output is correct
14 Incorrect 0 ms 344 KB Incorrect
15 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 Partially correct 133 ms 344 KB Output is partially correct
4 Partially correct 414 ms 344 KB Output is partially correct
5 Partially correct 840 ms 344 KB Output is partially correct
6 Correct 9 ms 344 KB Output is correct
7 Correct 18 ms 344 KB Output is correct
8 Partially correct 150 ms 344 KB Output is partially correct
9 Partially correct 311 ms 344 KB Output is partially correct
10 Partially correct 858 ms 344 KB Output is partially correct
11 Partially correct 836 ms 344 KB Output is partially correct
12 Partially correct 801 ms 344 KB Output is partially correct
13 Partially correct 809 ms 344 KB Output is partially correct
14 Incorrect 1 ms 596 KB Incorrect
15 Halted 0 ms 0 KB -