Submission #1547928
Source Code Expand
#include <stdio.h>
#include <stdlib.h>
#define MAX_N 100000
#define MAX_A 1000000000
long long int valid_num = 0;
long long int valid[MAX_N];
long long int hash[MAX_N*10];
long long int rehash_f(long long int num, int plus_num){
return (num + plus_num + rand()) % (MAX_N*10);
}
long long int hash_f(long long int num)
{
srand(10);
int b = (num + rand()) % (MAX_N*10);
if(hash[b] == num){
hash[b] = 0;
valid[valid_num] = num;
valid_num++;
}
else if(hash[b] != 0){
for(int i = 1; hash[b] != 0; i++){
b = rehash_f(num, i);
if(hash[b] == num){
hash[b] = 0;
valid[valid_num] = num;
valid_num++;
}
}
hash[b] = num;
}
else {
hash[b] = num;
}
}
int main()
{
long long int a[MAX_N];
long long int N;
long long int s;
for(int i = 0; i < N; i++){
hash[i] = 0;
}
scanf("%lld", &N);
for(int i = 0; i < N; i++){
scanf("%lld", &a[i]);
hash_f(a[i]);
}
if(valid_num >= 2){
long long int tmp = valid[0];
long long int max_i = 0;
for(int i = 1; i < valid_num; i++){
if(tmp < valid[i]){
tmp = valid[i];
max_i = i;
}
}
valid[max_i] = 0;
s = tmp;
tmp = valid[0];
max_i = 0;
for(int i = 1; i < valid_num; i++){
if(tmp < valid[i]){
tmp = valid[i];
max_i = i;
}
}
s = s * tmp;
printf("%lld\n", s);
} else {
printf("0\n");
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Make a Rectangle |
| User | ponntuu3 |
| Language | C++14 (GCC 5.4.1) |
| Score | 300 |
| Code Size | 1418 Byte |
| Status | AC |
| Exec Time | 147 ms |
| Memory | 9088 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:51:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &N);
^
./Main.cpp:53:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", &a[i]);
^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| 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 | AC | 147 ms | 9088 KiB |
| 2.txt | AC | 73 ms | 6784 KiB |
| 3.txt | AC | 146 ms | 9088 KiB |
| 4.txt | AC | 147 ms | 9088 KiB |
| 5.txt | AC | 73 ms | 6784 KiB |
| 6.txt | AC | 145 ms | 7296 KiB |
| 7.txt | AC | 145 ms | 7168 KiB |
| 8.txt | AC | 60 ms | 6784 KiB |
| 9.txt | AC | 75 ms | 8704 KiB |
| sample1.txt | AC | 1 ms | 2176 KiB |
| sample2.txt | AC | 0 ms | 128 KiB |
| sample3.txt | AC | 1 ms | 2176 KiB |