xi_inluogu @ 2023-11-23 14:56:33
#include<stdio.h>
int main()
{
int N;
scanf("%d", &N);
int cnt = 0;
int key = 1;
int num = 0;
int arr[420];
while (num != N * N)
{
int x;
scanf("%d", &x);
if (key) {
for (int i = 0; i < x; i++)
{
arr[num] = 0;
num++;
}
key = 0;
continue;
}
if (key == 0) {
for (int j = 0; j < x; j++)
{
arr[num] = 1;
num++;
}
key = 1;
continue;
}
}
for (int i = 0; i < N*N; i++)
{
printf("%d", arr[i]);
cnt++;
if (cnt == N) {
printf("\n");
cnt = 0;
}
}
return 0;
}
奇怪的是错误点开了O2优化就是RE,不开就是TLE,没看出代码有什么错误,大佬们教教。
by Hilte @ 2023-11-23 15:02:32
@xi_inluogu
int arr[420];
最多有
还有,大数组尽量开到main函数外
by xi_inluogu @ 2023-11-23 15:04:49
@Hilte 谢谢佬,我是笨比