답안 #611836

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
611836 2022-07-29T08:01:43 Z qwerasdfzxcl 우주 해적 (JOI14_space_pirate) C++14
10 / 100
2000 ms 2380 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
int adj[100100], idx[100100];
ll ans[100100], t;

void solve(int a, int b){
    int org = adj[a];
    adj[a] = b;

    vector<int> V = {0};
    int i;
    ll cur = t, len = 0;
    for (i=1;;i=adj[i]){
        if (idx[i]) {len = (int)V.size() - idx[i]; break;}

        V.push_back(i);
        idx[i] = (int)V.size()-1;
        --cur;
    }

    cur %= len;
    for (;cur;cur--){
        i = adj[i];
    }

    ans[i]++;

    for (auto &x:V) idx[x] = 0;
    adj[a] = org;
}

int main(){
    int n;
    scanf("%d %lld", &n, &t);
    for (int i=1;i<=n;i++) scanf("%d", adj+i);

    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++) solve(i, j);
    }

    for (int i=1;i<=n;i++) printf("%lld\n", ans[i]);
    return 0;
}

Compilation message

space_pirate.cpp: In function 'int main()':
space_pirate.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     scanf("%d %lld", &n, &t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
space_pirate.cpp:37:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     for (int i=1;i<=n;i++) scanf("%d", adj+i);
      |                            ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 308 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
3 Correct 3 ms 212 KB Output is correct
4 Correct 9 ms 212 KB Output is correct
5 Correct 8 ms 212 KB Output is correct
6 Correct 6 ms 212 KB Output is correct
7 Correct 10 ms 320 KB Output is correct
8 Correct 6 ms 212 KB Output is correct
9 Correct 9 ms 312 KB Output is correct
10 Correct 7 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 9 ms 340 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 6 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 308 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
3 Correct 3 ms 212 KB Output is correct
4 Correct 9 ms 212 KB Output is correct
5 Correct 8 ms 212 KB Output is correct
6 Correct 6 ms 212 KB Output is correct
7 Correct 10 ms 320 KB Output is correct
8 Correct 6 ms 212 KB Output is correct
9 Correct 9 ms 312 KB Output is correct
10 Correct 7 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 9 ms 340 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 6 ms 212 KB Output is correct
15 Execution timed out 2072 ms 352 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2068 ms 2380 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 308 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
3 Correct 3 ms 212 KB Output is correct
4 Correct 9 ms 212 KB Output is correct
5 Correct 8 ms 212 KB Output is correct
6 Correct 6 ms 212 KB Output is correct
7 Correct 10 ms 320 KB Output is correct
8 Correct 6 ms 212 KB Output is correct
9 Correct 9 ms 312 KB Output is correct
10 Correct 7 ms 324 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 9 ms 340 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 6 ms 212 KB Output is correct
15 Execution timed out 2072 ms 352 KB Time limit exceeded
16 Halted 0 ms 0 KB -