Xidian Online Judge WebBoard
[ New Thread ]
Problem 1001 >> 这提示有毒?
14030110093 @ 2017-05-19 23:21:12
[ Quote ] [ Edit ] [ Delete ] 1#

#include <stdio.h>
int main(){
int m,n;

int total = 0;
while (scanf("%d %d",&n,&m) != EOF) {
total ++;
printf("Case #%d:\n",total);
char field[n+1][m+1];//能直接开数组?
int nown[n+1],nowm[m+1];
int i,j;
for (i=1;i<=m;i++) nowm[i] = i;
for (i=1;i<=n;i++){
char row[1000001];
nown[i] = i;
for (j=1;j<=m;j++){
field[i][j] = row[j-1];
int q;
for (i=1;i<=q;i++){
int order,i1,i2;
scanf("%d %d %d",&order,&i1,&i2);
if (order == 1){
char now = field[nown[i1]][nowm[i2]];
if (now == 'T'){
else if (now == 'i'){
else printf("Empty\n");
if (order == 2){
int temp = nown[i1];
nown[i1] = nown[i2];
nown[i2] = temp;
if (order == 3){
int temp = nowm[i1];
nowm[i1] = nowm[i2];
nowm[i2] = temp;
return 0;
xry111 @ 2017-05-20 20:07:39
[ Quote ] [ Edit ] [ Delete ] 2#
This is a variable length array. It's not $10^6 \times 10^6$.

I don't like VLA since it's not conform to each version of C++ Standard. VLA is just a GNU extension, with a bunch of bugs. See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16994>. You may get strange WA/RE if you use VLA in
an important contest (Murphy Law).

In fact GCC users and developers aren't enthusiastic to fix VLA bugs. They just use -Werror=vla for C++.

But VLA is fully C99 standard. So use VLA in C99 (which is the C standard of XDOJ) is alright. But still you should
notice that VLAs are on the stack. If you have a large VLA it may lead to SIGSEGV. In this problem the VLA is just
1M and the stack limit of XDOJ is 8M.

Please don't criticize XDOJ administrators or problem setters for unspecified (esp. implementation-defined) or
undefined behaviour. For example, glibc has O(n+m) strstr() so someone may solve a KMP problem with it (on XDOJ). You shouldn't say "It's unfair! He doesn't know how to write KMP!" And you shouldn't say "I submitted his program to
Codeforces and got TLE!" And neither "I'm very clever! I can solve this problem with a single strstr() call!" And neither
"The problem setter is a fool! He can't hack my strstr() program!"
17130188019 @ 2017-11-26 23:21:28
[ Quote ] [ Edit ] [ Delete ] 3#
Restrictions of data input is not m<=10^6 && n<=10^6.
It is m*n<=10^6.
And you are using VLA, which means the max size of that array is only 10^6 B.
[Top] [Previous Page] [Next Page]
Anything about the Problems, Please Contact Admin:admin
All Copyright Reserved 2010-2014 Xidian ACM Online Judge TEAM
GPL2.0 2003-2014 HUSTOJ Project TEAM