Submission #848778

# Submission time Handle Problem Language Result Execution time Memory
848778 2023-09-13T13:33:49 Z emad234 Longest Trip (IOI23_longesttrip) C++17
5 / 100
45 ms 1224 KB
#include <bits/stdc++.h>
#define all(v) ((v).begin(),(v).end())
#define ll long long
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll mxN = 2e5 + 1;
using namespace std;
bool are_connected(vector<int> A, vector<int> B);
int Search(int x, vector<int>b){
  if(b.size() == 1) return b[0];
  vector<int>a = {x};
  vector<int> v,v1;
  for(int i = 0;i < b.size() / 2;i++) v.push_back(b[i]);
  for(int i = b.size() / 2;i < b.size();i++) v1.push_back(b[i]);
  if(v.size() && are_connected(a,v)) return Search(x,v);
  else if(v1.size() && are_connected(a,v1)) return Search(x,v1);
  return -1;
}
bool vis[mxN];
vector<int> longest_trip(int N, int D)
{
  memset(vis,0,N + 3);
  vector<int>ans = {0};
  vis[0] = 1;
  while(ans.size() < N){
    vector<int>b;
    for(int i = 0;i < N;i++){
      if(!vis[i]) b.push_back(i);
    }
    int x = Search(ans[ans.size() - 1],b);
    ans.push_back(x);
    vis[x] = 1;
  }
  return ans;
}

Compilation message

longesttrip.cpp: In function 'int Search(int, std::vector<int>)':
longesttrip.cpp:14:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for(int i = 0;i < b.size() / 2;i++) v.push_back(b[i]);
      |                 ~~^~~~~~~~~~~~~~
longesttrip.cpp:15:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int i = b.size() / 2;i < b.size();i++) v1.push_back(b[i]);
      |                            ~~^~~~~~~~~~
longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:26:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |   while(ans.size() < N){
      |         ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB invalid array
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 8 ms 344 KB Output is correct
3 Correct 21 ms 344 KB Output is correct
4 Correct 30 ms 452 KB Output is correct
5 Correct 44 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 10 ms 344 KB Output is correct
3 Correct 21 ms 600 KB Output is correct
4 Correct 29 ms 452 KB Output is correct
5 Correct 41 ms 1220 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 4 ms 344 KB Output is correct
2 Correct 8 ms 344 KB Output is correct
3 Correct 20 ms 344 KB Output is correct
4 Correct 27 ms 448 KB Output is correct
5 Correct 35 ms 1224 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 4 ms 344 KB Output is correct
2 Correct 11 ms 344 KB Output is correct
3 Correct 22 ms 600 KB Output is correct
4 Partially correct 27 ms 448 KB Output is partially correct
5 Partially correct 45 ms 712 KB Output is partially correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -