Submission #80755

# Submission time Handle Problem Language Result Execution time Memory
80755 2018-10-22T08:57:09 Z farukkastamonuda The Kingdom of JOIOI (JOI17_joioi) C++14
60 / 100
1490 ms 263168 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define li 2005
#define mp make_pair
#define pb push_back
using namespace std;
int n,m,A[li][li],mn=md,mx;
bool check(int val){
	int mxj=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(A[i][j]<mx-val) mxj=max(mxj,j+1);
		}
		for(int j=1;j<=m;j++){
			if(mn+val<A[i][j] && j<mxj) return false;
		}
	}
	return true;
}
int solve(){
	int bas=0,son=mx-mn;
	while(bas<=son){
		//cout<<"debig->:: "<<bas<<' '<<son<<endl;
		int mid=(bas+son)/2;
		if(check(mid)) son=mid-1;
		else bas=mid+1;
	}
	return bas;
}
void flip_row(){
	for(int i=1;i<=n/2;i++){
		for(int j=1;j<=m;j++){
			swap(A[i][j],A[n-i+1][j]);
		}
	}
}
void flip_col(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m/2;j++){
			swap(A[i][j],A[i][m-j+1]);
		}
	}
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			scanf("%d",&A[i][j]);
			mx=max(mx,A[i][j]);
			mn=min(mn,A[i][j]);
		}
	}
	int ty=solve();
	//printf("%d\n",ty);
	flip_row();
	ty=min(ty,solve());
	flip_col();
	ty=min(ty,solve());
	flip_row();
	ty=min(ty,solve());
	printf("%d\n",ty);
	return 0;
}

Compilation message

joioi.cpp: In function 'int main()':
joioi.cpp:49:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
joioi.cpp:52:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&A[i][j]);
    ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 636 KB Output is correct
3 Correct 2 ms 636 KB Output is correct
4 Correct 2 ms 772 KB Output is correct
5 Correct 2 ms 772 KB Output is correct
6 Correct 2 ms 796 KB Output is correct
7 Correct 2 ms 796 KB Output is correct
8 Correct 2 ms 896 KB Output is correct
9 Correct 2 ms 896 KB Output is correct
10 Correct 2 ms 900 KB Output is correct
11 Correct 2 ms 908 KB Output is correct
12 Correct 2 ms 908 KB Output is correct
13 Correct 2 ms 912 KB Output is correct
14 Correct 2 ms 912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 636 KB Output is correct
3 Correct 2 ms 636 KB Output is correct
4 Correct 2 ms 772 KB Output is correct
5 Correct 2 ms 772 KB Output is correct
6 Correct 2 ms 796 KB Output is correct
7 Correct 2 ms 796 KB Output is correct
8 Correct 2 ms 896 KB Output is correct
9 Correct 2 ms 896 KB Output is correct
10 Correct 2 ms 900 KB Output is correct
11 Correct 2 ms 908 KB Output is correct
12 Correct 2 ms 908 KB Output is correct
13 Correct 2 ms 912 KB Output is correct
14 Correct 2 ms 912 KB Output is correct
15 Correct 2 ms 1048 KB Output is correct
16 Correct 7 ms 1952 KB Output is correct
17 Correct 11 ms 2300 KB Output is correct
18 Correct 10 ms 2588 KB Output is correct
19 Correct 20 ms 2860 KB Output is correct
20 Correct 12 ms 3020 KB Output is correct
21 Correct 14 ms 3516 KB Output is correct
22 Correct 15 ms 3904 KB Output is correct
23 Correct 18 ms 4288 KB Output is correct
24 Correct 14 ms 4692 KB Output is correct
25 Correct 21 ms 5036 KB Output is correct
26 Correct 17 ms 5552 KB Output is correct
27 Correct 14 ms 5812 KB Output is correct
28 Correct 14 ms 6200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 636 KB Output is correct
3 Correct 2 ms 636 KB Output is correct
4 Correct 2 ms 772 KB Output is correct
5 Correct 2 ms 772 KB Output is correct
6 Correct 2 ms 796 KB Output is correct
7 Correct 2 ms 796 KB Output is correct
8 Correct 2 ms 896 KB Output is correct
9 Correct 2 ms 896 KB Output is correct
10 Correct 2 ms 900 KB Output is correct
11 Correct 2 ms 908 KB Output is correct
12 Correct 2 ms 908 KB Output is correct
13 Correct 2 ms 912 KB Output is correct
14 Correct 2 ms 912 KB Output is correct
15 Correct 2 ms 1048 KB Output is correct
16 Correct 7 ms 1952 KB Output is correct
17 Correct 11 ms 2300 KB Output is correct
18 Correct 10 ms 2588 KB Output is correct
19 Correct 20 ms 2860 KB Output is correct
20 Correct 12 ms 3020 KB Output is correct
21 Correct 14 ms 3516 KB Output is correct
22 Correct 15 ms 3904 KB Output is correct
23 Correct 18 ms 4288 KB Output is correct
24 Correct 14 ms 4692 KB Output is correct
25 Correct 21 ms 5036 KB Output is correct
26 Correct 17 ms 5552 KB Output is correct
27 Correct 14 ms 5812 KB Output is correct
28 Correct 14 ms 6200 KB Output is correct
29 Correct 833 ms 42448 KB Output is correct
30 Correct 748 ms 64820 KB Output is correct
31 Correct 842 ms 88060 KB Output is correct
32 Correct 675 ms 111068 KB Output is correct
33 Correct 614 ms 129076 KB Output is correct
34 Correct 788 ms 154224 KB Output is correct
35 Correct 1233 ms 193228 KB Output is correct
36 Correct 1012 ms 226732 KB Output is correct
37 Runtime error 1490 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.