Submission #1047104

#TimeUsernameProblemLanguageResultExecution timeMemory
1047104Ahmed57Ancient Books (IOI17_books)C++17
0 / 100
0 ms348 KiB
#include "bits/stdc++.h" using namespace std; vector<int> P; int vis[1001]; void dfs(int i){ vis[i] = 1; if(!vis[P[i]])dfs(P[i]); } long long minimum_walk(vector<int> p, int s){ int ans = 0; int n = p.size(); P.clear(); for(int i = 0;i<n;i++){ vis[i] = 0; P.push_back(p[i]); ans+=abs(i-p[i]); } vector<int> lol; for(int i = 0;i<n;i++){ if(!vis[i]){ dfs(i); lol.push_back(i); } } int sz = lol.size(); for(int i = 0;i<lol.size();i++){ ans+=abs(lol[i]-lol[(i+1)%sz]); } return ans; }

Compilation message (stderr)

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0;i<lol.size();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...