Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 所有数据都过了非要说wa，你狠老子不做了

Posted by JeremyCorbyn at 2018-02-12 00:33:09 on Problem 1026
```#include<stdio.h>
#include<string.h>

int main()
{
int n, i, j, k, len, m[200], cnt, cph[200], itmp;
char msg[200], mtmp[200];
bool mk[200];
while (scanf_s("%d", &n) && n)
{
for (i = 0; i < n; i++)
scanf_s("%d", cph + i);
memset(mk, 0, sizeof(mk));
memset(m, 0, sizeof(m));
for (i = 0; i < n; i++)
if (mk[i] == false)
{
mk[i] = true;
j = i;
cnt = 1;
while (cph[j] - 1 != i)
{
cnt++;
mk[cph[j] - 1] = 1;
j = cph[j] - 1;
}
j = i;
do {
m[j] = cnt;
j = cph[j] - 1;
} while (j != i);
}
while (scanf_s("%d", &k) && k)
{
getchar();
gets_s(msg);
len = strlen(msg);
for (i = 0; i < n - len; i++)
msg[len + i] = ' ';
msg[n] = '\0';
for (i = 0; i < n; i++)
{
itmp = i;
for (j = 0; j < k%m[i]; j++)
itmp = cph[itmp] - 1;
mtmp[itmp] = msg[i];
}
mtmp[n] = '\0';
printf("%s\n", mtmp);
}
printf("\n");
}
return 0;
}```

Followed by: