# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
566287 | 2022-05-22T08:14:03 Z | sofapuden | 고대 책들 (IOI17_books) | C++14 | 1 ms | 340 KB |
#include "books.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; ll minimum_walk(vector<int> p, int s) { ll su = 0; int mx = 0; int n = p.size(); vector<int> vis(n,0); vector<int> cnt(n+1,0); ll ans = 0; int cn = 0; vector<vector<int>> gr(n+1); for(int i = 0; i < n; ++i){ if(!vis[i]){ cn++; while(!vis[i]){ ans+=abs(i-p[i]); vis[i] = cn; cnt[cn]++; i = p[i]; } } } int dif = 0; vector<int> cnt2(n+1,0); for(int i = 0; i < n; ++i){ if(!cnt2[vis[i]]++)dif++; if(cnt2[vis[i]] == cnt[vis[i]])dif--; if(!dif)ans+=2; } return ans-2; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 292 KB | Output is correct |
5 | Incorrect | 1 ms | 300 KB | 3rd lines differ - on the 1st token, expected: '4', found: '6' |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 292 KB | Output is correct |
5 | Incorrect | 1 ms | 300 KB | 3rd lines differ - on the 1st token, expected: '4', found: '6' |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 292 KB | Output is correct |
5 | Incorrect | 1 ms | 300 KB | 3rd lines differ - on the 1st token, expected: '4', found: '6' |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | 3rd lines differ - on the 1st token, expected: '3304', found: '2744' |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 292 KB | Output is correct |
5 | Incorrect | 1 ms | 300 KB | 3rd lines differ - on the 1st token, expected: '4', found: '6' |
6 | Halted | 0 ms | 0 KB | - |