#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define clr(dp,i) memset(dp,i,sizeof(dp))
#define opt ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define inf 0x3f3f3f3f
using namespace std;
using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_t_tag,
//t_order_statistics_node_update> oset;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const long long mod = 1e9+7;
const ld pi = 3.14159265358979323846264338327950288;
//==================================================
const int N = 101;
int n, m, node[N], child[N], cnt[N];
int vis[N];
int t;
void dfs(int i)
{
t++;
//cout << i << t << " ";
if(vis[i])
{
//cout << endl;
//cout << t << " " << vis[i] << " | "<< node[vis[i] + (m%(t-vis[i]))] << endl;
cnt[node[vis[i] + (m%(t-vis[i]+1))] ]++;
return ;
}
vis[i] = t, node[t] = i;
dfs(child[i]);
}
int main()
{
cin >> n >> m;
for(int i=0; i<n; i++)
cin >> child[i], child[i]--;
for(int i=0; i<n; i++)
{
for(int j=0; j<n; j++)
{
//cout << endl;
clr(vis, 0);
clr(node, 0);
int tmp = child[i];
t = 0;
child[i] = j;
//cout << i << " " << j << endl;
dfs(0);
child[i] = tmp;
}
}
swap(cnt[0], cnt[n-1]);
for(int i=0; i<n; i++)
cout << cnt[i] << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
376 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
376 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
376 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |