QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#345233 | #7933. Build Permutation | yby | Compile Error | / | / | C99 | 901b | 2024-03-06 16:58:56 | 2024-03-06 16:58:56 |
Judging History
answer
#include <stdio.h>
#define N 200020
long a[N], long[N];
long ans[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (int i = 1; i <= n; i++)
p[i] = i;
for (int i = 1; i <= n; i++)
{
for (int j = i + 1; j <= n; j++)
{
if (a[p[i]] > a[p[j]])
{
int temp = p[i];
p[i] = p[j];
p[j] = temp;
}
}
}
int s = a[p[1]] + a[p[n]];
for (int i = 1; i <= n; i++)
{
if (a[p[i]] + a[p[n - i + 1]] != s)
{
printf("-1\n");
return 0;
}
}
for (int i = 1; i <= n; i++)
ans[p[i]] = p[n - i + 1];
for (int i = 1; i <= n; i++)
printf("%d ", ans[i]);
printf("\n");
return 0;
}
Details
answer.code:5:12: error: expected identifier or ‘(’ before ‘long’ 5 | long a[N], long[N]; | ^~~~ answer.code: In function ‘main’: answer.code:13:17: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘long int *’ [-Wformat=] 13 | scanf("%d", &a[i]); | ~^ ~~~~~ | | | | | long int * | int * | %ld answer.code:15:9: error: ‘p’ undeclared (first use in this function) 15 | p[i] = i; | ^ answer.code:15:9: note: each undeclared identifier is reported only once for each function it appears in answer.code:42:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=] 42 | printf("%d ", ans[i]); | ~^ ~~~~~~ | | | | int long int | %ld answer.code:11:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] 11 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ answer.code:13:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] 13 | scanf("%d", &a[i]); | ^~~~~~~~~~~~~~~~~~