# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
165289 | Segtree | 고대 책들 (IOI17_books) | C++14 | 187 ms | 13232 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<algorithm>
#include<vector>
#include"books.h"
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define N 1000010
ll minimum_walk(vector<int> p,int s){
int n=p.size();
ll sum=0;
for(int i=0;i<n;i++)sum+=abs(i-p[i]);
bool vis[N];
for(int i=0;i<n;i++)vis[i]=0;
vector<pair<int,int> >v;
bool th=0;
for(int i=0;i<n;i++){
if(vis[i])continue;
ll x=i;
ll mi=1e17,ma=-1e17;
while(1){
chmin(mi,x);
chmax(ma,x);
vis[x]=1;
x=p[x];
if(x==i)break;
}
if(mi!=ma){
v.push_back(make_pair(mi,ma));
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |