Submission #1792151


Source Code Expand

#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 2200000 
#define MAXCARDS 100000

int alNumber[MAXCARDS];
int alTimes[MAXCARDS];
char sInput[MAX_STRING];

int main() {

	char* psInput;
	long long l=0;
	int i=0;
	int j=0;
	int lTemp2=0;
	int lKinds=0;
	int  lCardsNumber =0;
	int  lMax = 0;
	int  lTop = 0;
	int  lSecond = 0;
	int  lSquare = 0;
	int  lTarget=0;
	int  lFound=0;
	int  lAnswer=0;
	int  lTimes=0;
	int  lNumber=0;

	// read line 1
	gets(sInput);
	lCardsNumber = atol(sInput);
	//format
	for (i=0;i<lCardsNumber;i++){
//		alNumber[i]=0;
		alTimes[i]=0;
	}
	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (i=0;i<lCardsNumber;i++){
		lTemp2=atol(psInput);
		lFound=0;
		for (j=0;j<lKinds;j++){
			if(alNumber[j]==lTemp2){
				alTimes[j]=alTimes[j]+1;
				lFound=1;
			}
		}
		if (lFound==0){
			alNumber[lKinds]=lTemp2;
			alTimes[lKinds]=alTimes[lKinds]+1;
			lKinds++;
		}
/*		if (lMax<lTemp2){
			lMax=lTemp2;
		}*/
		if (i<lCardsNumber){
			psInput = strtok(NULL," ");
		}
	}

	for (i=0;i<lKinds;i++){
		lTimes=alTimes[i];
		lNumber=alNumber[i];
		if(lTimes>=4){
			if(lNumber>lSquare){
				lSquare = lNumber;
			}
		}
		if(lTimes>=2){
			if(lNumber>lTop){
				lSecond = lTop;
				lTop = lNumber;
			} else if (lNumber>lSecond){
				lSecond = lNumber;
			}
		}
	}
	/*
	for (lTarget=lMax;lTarget>0;lTarget--){
		lTimes=0;
		for(j=0;j<lKinds;j++){
			if(alNumber[j]==lTarget){
				lTimes=alTimes[j];
			}
		}

		if(lTimes>=4&&lSquare==0){
			lSquare=lTarget;
		} 
		if(lTimes>=2){
			if(lTop==0){
				lTop=lTarget;
			} else if (lSecond==0) {
				lSecond=lTarget;
			}
		}
		if(lTarget+10<lSecond||lTarget+10<lSquare){
			break;
		}
	}*/
	lAnswer=lTop*lSecond;
	if (lAnswer<lSquare*lSquare){
			lAnswer=lSquare*lSquare;
	}
	printf("%ld\n",lAnswer);

    return 0;
}

Submission Info

Submission Time
Task C - Make a Rectangle
User unirita137
Language C (GCC 5.4.1)
Score 0
Code Size 1989 Byte
Status WA
Exec Time 2103 ms
Memory 1792 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:33:2: warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration]
  gets(sInput);
  ^
./Main.c:109:9: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
  printf("%ld\n",lAnswer);
         ^
/tmp/cc8NRCva.o: In function `main':
Main.c:(.text.startup+0xc): warning: the `gets' function is dangerous and should not be used.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 7
WA × 6
TLE × 2
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt TLE 2103 ms 1792 KB
2.txt WA 7 ms 896 KB
3.txt TLE 2103 ms 1792 KB
4.txt WA 1845 ms 1664 KB
5.txt WA 6 ms 896 KB
6.txt WA 15 ms 1536 KB
7.txt WA 13 ms 1536 KB
8.txt WA 6 ms 768 KB
9.txt AC 815 ms 1024 KB
sample1.txt AC 1 ms 128 KB
sample2.txt AC 1 ms 128 KB
sample3.txt AC 1 ms 128 KB