Submission #425491

#TimeUsernameProblemLanguageResultExecution timeMemory
425491Charis02고대 책들 (IOI17_books)C++14
0 / 100
1 ms332 KiB
#include "books.h" #include<iostream> #include<vector> #include<map> #define ll long long #define rep(i,a,b) for(int i = a;i < b;i++) #define mp(a,b) make_pair(a,b) #define N 100003 using namespace std; bool vis[N]; int abso(int x) { return (x < 0) ? -x : x; } ll get_cycle_cost(vector < int > c) { if(c.size()==1) return 0; ll res = 0; rep(i,1,c.size()) { res += abso(c[i]-c[i-1]); } res += abso(c[0]-c[c.size()-1]); return res; } long long minimum_walk(std::vector<int> p, int s) // for 1st sub { int n = p.size(); vector < vector < int > > cycles; rep(i,0,n) { if(vis[i]) continue; int cur = i; int ind = cycles.size(); cycles.push_back(vector < int >()); // cout << "here "; while(!vis[cur]) { // cout << cur << " "; vis[cur] = true; cycles[ind].push_back(cur); cur = p[cur]; } // cout << endl; } ll ans = 0; int last = 0; rep(i,0,cycles.size()) { ans += get_cycle_cost(cycles[i]); if(cycles[i].size() > 1) last = cycles[i][0]; } ans += last*2; return ans; }

Compilation message (stderr)

books.cpp: In function 'long long int get_cycle_cost(std::vector<int>)':
books.cpp:6:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define rep(i,a,b) for(int i = a;i < b;i++)
......
   26 |     rep(i,1,c.size())
      |         ~~~~~~~~~~~~                
books.cpp:26:5: note: in expansion of macro 'rep'
   26 |     rep(i,1,c.size())
      |     ^~~
books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:6:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define rep(i,a,b) for(int i = a;i < b;i++)
......
   66 |     rep(i,0,cycles.size())
      |         ~~~~~~~~~~~~~~~~~           
books.cpp:66:5: note: in expansion of macro 'rep'
   66 |     rep(i,0,cycles.size())
      |     ^~~
#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...