답안 #52186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52186 2018-06-24T14:26:15 Z `مرحبا بالعالم`(#1336) 우주 해적 (JOI14_space_pirate) C++11
10 / 100
2000 ms 2368 KB
#include <bits/stdc++.h>
#define dbgv(v) {for(auto x:v)cout<<x<<' ';cout<<'\n';}
#define entire(v) v.begin(),v.end()
typedef long long ll;
using namespace std;
void OJize(){
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    #ifdef jh
    freopen("input.txt", "r", stdin);
    #endif
}

int kth(vector<int> &perm, ll k){
    vector<int> visit(perm.size());
    int p = 1, i = 1;
    if(k <= 110){
        for(int i=0; i<k; i++) p = perm[p];
        return p;
    }
    while(!visit[p]) visit[p] = i++, p = perm[p], k--;
    k%= i - visit[p];
    for(int i=0; i<k; i++) p = perm[p];
    return p;
}

int main(){OJize();
    int n; ll k; cin>>n>>k;
    vector<int> perm(n+1);
    for(int i=0; i<n; i++) cin>>perm[i+1];
    vector<int> ans(n+1);
    for(int i=1; i<=n; i++) for(int j=1; j<=n; j++){
        int orig = perm[i];
        perm[i] = j;
        ans[kth(perm, k)]++;
        perm[i] = orig;
    }
    for(int i=1; i<=n; i++) cout << ans[i] << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 252 KB Output is correct
2 Correct 4 ms 356 KB Output is correct
3 Correct 4 ms 436 KB Output is correct
4 Correct 6 ms 556 KB Output is correct
5 Correct 5 ms 556 KB Output is correct
6 Correct 5 ms 572 KB Output is correct
7 Correct 6 ms 676 KB Output is correct
8 Correct 5 ms 676 KB Output is correct
9 Correct 6 ms 676 KB Output is correct
10 Correct 5 ms 676 KB Output is correct
11 Correct 3 ms 676 KB Output is correct
12 Correct 6 ms 676 KB Output is correct
13 Correct 7 ms 792 KB Output is correct
14 Correct 6 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 252 KB Output is correct
2 Correct 4 ms 356 KB Output is correct
3 Correct 4 ms 436 KB Output is correct
4 Correct 6 ms 556 KB Output is correct
5 Correct 5 ms 556 KB Output is correct
6 Correct 5 ms 572 KB Output is correct
7 Correct 6 ms 676 KB Output is correct
8 Correct 5 ms 676 KB Output is correct
9 Correct 6 ms 676 KB Output is correct
10 Correct 5 ms 676 KB Output is correct
11 Correct 3 ms 676 KB Output is correct
12 Correct 6 ms 676 KB Output is correct
13 Correct 7 ms 792 KB Output is correct
14 Correct 6 ms 792 KB Output is correct
15 Execution timed out 2067 ms 792 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2058 ms 2368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 252 KB Output is correct
2 Correct 4 ms 356 KB Output is correct
3 Correct 4 ms 436 KB Output is correct
4 Correct 6 ms 556 KB Output is correct
5 Correct 5 ms 556 KB Output is correct
6 Correct 5 ms 572 KB Output is correct
7 Correct 6 ms 676 KB Output is correct
8 Correct 5 ms 676 KB Output is correct
9 Correct 6 ms 676 KB Output is correct
10 Correct 5 ms 676 KB Output is correct
11 Correct 3 ms 676 KB Output is correct
12 Correct 6 ms 676 KB Output is correct
13 Correct 7 ms 792 KB Output is correct
14 Correct 6 ms 792 KB Output is correct
15 Execution timed out 2067 ms 792 KB Time limit exceeded
16 Halted 0 ms 0 KB -