#22

by asd

Submitted 2 years 11 months ago
Mon May 10 18:05:42 CST 2021
Judger: judger1
Dataset Version: v3

121 ms / 43856 KB
Final 0
Problem: lss1.trifang
Language: GNU C++ 11


#1

2ms / 8836KB / Accepted
Input
2 8 1
26500 19169 15724 11478 29358 26962 24464 5705 
28145 23281 16827 9961 491 2995 11942 4827 
Output
29358
Answer
29358
Checker Information
"29358"

#2

2ms / 8832KB / Accepted
Input
7 2 1
3902 153 
292 12382 
17421 18716 
19718 19895 
5447 21726 
14771 11538 
1869 19912 
Output
21726
Answer
21726
Checker Information
"21726"

#3

3ms / 8820KB / Accepted
Input
8 10 4
9894 28703 23811 31322 30333 17673 4664 15141 7711 28253 
6868 25547 27644 32662 32757 20037 12859 8723 9741 27529 
778 12316 3035 22190 1842 288 30106 9040 8942 19264 
22648 27446 23805 15890 6729 24370 15350 15006 31101 24393 
3548 19629 12623 24084 19954 18756 11840 4966 7376 13931 
26308 16944 32439 24626 11323 5537 21538 16118 2082 22929 
16541 4833 31115 4639 29658 22704 9930 13977 2306 31673 
22386 5021 28745 26924 19072 6270 5829 26777 15573 5097 
Output
336998
Answer
336998
Checker Information
"336998"

#4

3ms / 8820KB / Accepted
Input
3 7 1
9161 18636 22355 24767 23655 15574 4031 
12052 27350 1150 16941 21724 13966 3430 
31107 30191 18007 11337 15457 12287 27753 
Output
31107
Answer
31107
Checker Information
"31107"

#5

2ms / 8764KB / Wrong Answer
Input
4 6 2
32209 9758 24221 18588 6422 24946 
27506 13030 16413 29168 900 32591 
18762 1655 17410 6359 27624 20537 
21548 6483 27595 4041 3602 24350 
Output
71074
Answer
105102
Checker Information
1st words differ - expected: '105102', found: '71074'

#1

5ms / 8784KB / Accepted
Input
42 68 14
26500 19169 15724 11478 29358 26962 24464 5705 28145 23281 16827 9961 491 2995 11942 4827 5436 32391 14604 3902 153 292 12382 17421 18716 19718 19895 5447 21726 14771 11538 1869 19912 25667 26299 17035 9894 28703 23811 31322 30333 17673 4664 15141 7711 28253 6868 25547 27644 32662 32757 20037 12859 8723 9741 27529 778 12316 3035 22190 1842 288 30106 9040 8942 19264 22648 27446 
23805 15890 6729 24370 15350 15006 31101 24393 3548 19629 12623 24084 19954 18756 11840 4966 7376 13931 26308 16944 32439 24626 11323 5537 21538 16118 2082 22929 16541 4833 31115 4639 29658 22704 9930 13977 2306 31673 22386 5021 28745 26924 19072 6270 5829 26777 15573 5097 16512 23986 13290 9161 18636 22355 24767 23655 15574 4031 12052 27350 1150 16941 21724 13966 3430 31107 30191 18007 
11337 15457 12287 27753 10383 14945 8909 32209 9758 24221 18588 6422 24946 27506 13030 16413 29168 900 32591 18762 1655 17410 6359 27624 20537 21548 6483 27595 4041 3602 24350 10291 30836 9374 11020 4596 24021 27348 23199 19668 24484 8281 4<...>
Output
3489234
Answer
3489234
Checker Information
"3489234"

#2

6ms / 8832KB / Wrong Answer
Input
93 65 26
18866 14693 30664 23775 13000 12212 21100 7551 25476 6379 10943 17877 3789 361 11385 8272 11434 15144 29561 25563 14504 12946 23888 20308 12157 1430 5123 6464 4074 4346 13837 1981 25318 26611 16292 17591 3832 27123 6461 16991 31461 27330 28498 17369 17291 8400 14179 24117 2317 19914 1595 1441 5936 21867 7028 31453 27909 13973 17981 11503 26569 6816 1883 25367 5385 
28402 5230 17157 28681 15567 8310 1866 3687 13171 3477 31245 32764 6238 27671 2047 26115 4592 27311 32657 1405 53 7171 20580 22740 22530 13675 24320 25790 13377 10998 16586 21604 4489 19631 29744 8388 26610 18718 26919 18259 5927 14609 28119 21479 22716 6300 21396 16853 11458 20830 24593 30806 29849 14854 24272 26160 12294 12054 26333 146 4229 10471 10428 10559 22241 
29421 22688 16366 12033 26685 2270 25329 32261 22860 2208 8982 22162 32506 6878 11979 1897 7887 6538 14469 30783 17540 22795 7266 18633 13509 24557 2317 26134 32053 18135 12258 2593 17843 21693 16466 22951 18140 11094 12937 5174 2512 6097 9551 2695 21817 23492 21292 20237 <...>
Output
11543750
Answer
11572908
Checker Information
1st words differ - expected: '11572908', found: '11543750'

#1

10ms / 11256KB / Accepted
Input
42 468 14
26500 19169 15724 11478 29358 26962 24464 5705 28145 23281 16827 9961 491 2995 11942 4827 5436 32391 14604 3902 153 292 12382 17421 18716 19718 19895 5447 21726 14771 11538 1869 19912 25667 26299 17035 9894 28703 23811 31322 30333 17673 4664 15141 7711 28253 6868 25547 27644 32662 32757 20037 12859 8723 9741 27529 778 12316 3035 22190 1842 288 30106 9040 8942 19264 22648 27446 23805 15890 6729 24370 15350 15006 31101 24393 3548 19629 12623 24084 19954 18756 11840 4966 7376 13931 26308 16944 32439 24626 11323 5537 21538 16118 2082 22929 16541 4833 31115 4639 29658 22704 9930 13977 2306 31673 22386 5021 28745 26924 19072 6270 5829 26777 15573 5097 16512 23986 13290 9161 18636 22355 24767 23655 15574 4031 12052 27350 1150 16941 21724 13966 3430 31107 30191 18007 11337 15457 12287 27753 10383 14945 8909 32209 9758 24221 18588 6422 24946 27506 13030 16413 29168 900 32591 18762 1655 17410 6359 27624 20537 21548 6483 27595 4041 3602 24350 10291 30836 9374 11020 4596 24021 27348 23199 19668 24484 8281 4734<...>
Output
3628190
Answer
3628190
Checker Information
"3628190"

#2

121ms / 38204KB / Accepted
Input
396 779 34
18689 32264 15410 19108 25202 14285 28381 15349 30402 13648 27958 27012 19594 4058 25652 8696 14115 20334 30106 4760 14090 6562 31612 3259 31113 17070 9471 16255 31636 29891 20576 14782 21490 24990 17976 18494 26781 12892 14846 1064 4970 10640 13261 9660 31212 11155 18279 28482 7318 8475 15483 17476 24865 26639 3107 16634 7213 18074 22449 26118 24107 5247 15531 11362 1914 3756 10772 5526 26576 2321 6893 3118 27868 29362 23036 10347 9258 24571 13004 11577 5190 3924 13301 20833 12580 7158 26269 10496 28607 21245 7999 17208 15617 24254 19372 20517 23523 15450 25167 25362 28373 12180 22196 9453 12384 10463 14156 2809 7946 20923 22634 26051 8314 13122 12434 23639 24540 11006 18931 10163 27527 8702 27954 8828 21981 14889 26985 240 23923 26066 7536 17692 24691 7564 9819 17231 7998 10303 22339 19150 4693 10619 24138 18121 22393 27149 15065 27534 31249 3792 26924 17405 6861 12742 26385 13116 14985 4455 30188 16044 11380 19001 15871 13339 29553 20129 14056 59 3773 4345 31083 18770 31186 5090 24178 8756 2548<...>
Output
20373162
Answer
20373162
Checker Information
"20373162"

#3

81ms / 30092KB / Accepted
Input
310 681 61
2959 31511 24294 7351 26164 1245 27572 4648 25487 24577 7142 2807 29239 2322 24800 15814 3539 28262 2988 9034 18641 8964 17481 24659 7771 14528 2885 4358 8326 1448 31118 22893 22221 22687 12933 24371 24767 24904 15444 4264 12532 20262 12929 23819 29765 27649 1732 16905 31036 13707 17430 21121 11210 14915 2059 6794 31032 15770 9825 1207 12384 26452 10969 9370 12829 562 11589 2694 1536 3534 11235 1177 10053 10182 24553 28922 7685 4124 16481 1376 14509 19677 10039 12244 31150 12545 19601 29879 3446 19091 3166 28166 23712 31762 10802 20445 3687 17686 1873 5690 3937 32310 32522 16388 28778 3114 23878 15180 12765 20013 9056 26322 20235 19365 3895 19659 7653 25862 6274 31457 22268 3060 22628 7036 22956 18088 3905 13376 147 660 15567 11735 6728 31306 32368 2288 23114 12954 10175 25735 22071 21242 18792 14695 25407 23852 6718 28398 26583 2074 30343 11537 30130 16901 27034 3999 16365 7646 30125 7882 16778 12276 3560 12515 10271 7632 30398 6501 22223 25949 124 18741 5498 8013 20514 17448 16433 16567 10867 40<...>
Output
63173817
Answer
63173817
Checker Information
"63173817"

#4

109ms / 43856KB / Wrong Answer
Input
725 442 311
11037 8735 2990 22511 14925 22528 8687 18110 19826 8996 18706 29929 8305 14565 26071 26051 21666 29514 28665 24750 18485 23258 9392 27020 31950 690 17018 7543 20851 27350 12827 18354 5032 23749 16610 17119 11224 30288 20527 31346 26871 22187 7730 8293 12134 8645 3061 27438 3863 19925 1181 28654 1265 28469 27117 27883 27510 30324 10763 6208 24227 5287 25223 18131 5911 14847 13465 32648 120 25249 11946 20148 3859 9649 28438 28117 6338 15024 25649 4992 13587 26889 19848 32666 26790 5606 25193 6091 8151 25672 16805 10288 15517 6999 3732 7248 15282 18167 24410 17490 13557 18075 24681 31341 15116 15966 20807 15519 24141 7760 16018 3746 22239 13325 7489 14364 6684 31381 11052 13078 24378 7255 14543 24239 22315 23439 16458 18961 7105 21714 28077 11173 6678 20455 31859 22659 31787 4825 3660 20525 21967 27466 24352 12412 6339 25098 31312 9690 5147 19689 21823 11186 743 13001 29457 12581 28179 13815 30130 30207 25996 30907 16410 13289 21668 12333 3536 26592 30136 22859 9133 20453 10512 17481 32227 28918 130<...>
Output
0
Answer
1587819050
Checker Information
1st words differ - expected: '1587819050', found: '0'
/*
Though leaves are many, the root is one;
Through all the lying days of my youth
I swayed my leaves and flowers in the sun,
Now may I wither into the truth.
 
- William Butler Yeats
*/
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
#include <bitset>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;
 
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
#define dbg if(false)
/**==Info==
*Program:1
*Problem:Rhombus
*Date:2019-12-30
*Algorithm:My rubbish prefix sum and violence
*Status:Unknown*/
 
bool debug=false;
 
ll n,m,k;
ll a[1005][1005];
ll tri[4][1005][1005];
 
ll colsum[1005][1005],rowsum[1005][1005];
 
int dsuid[1005][1005],dsuind[1005][1005];
ll dsusum[2005][2005];
int dsdid[1005][1005],dsdind[1005][1005];
ll dsdsum[2005][2005];
ll f[1005][1005];
 
int dsuic,dsdic;
 
const int L=0,R=1;
 
void runDsu(int x,int y){
	int cnt=0;
	
	while(true){
		dsuid[x][y]=dsuic;
		dsuind[x][y]=cnt;
		dsusum[dsuic][cnt]=(cnt==0?0:dsusum[dsuic][cnt-1])+a[x][y];
		cnt++;
		x--;y++;
		if(x<0 || y>=m){
			break;
		}
	}
	dsuic++;
}
 
void runDsd(int x,int y){
	int cnt=0;
	
	while(true){
		dsdid[x][y]=dsdic;
		dsdind[x][y]=cnt;
		dsdsum[dsdic][cnt]=(cnt==0?0:dsdsum[dsdic][cnt-1])+a[x][y];
		cnt++;
		x++;y++;
		if(x>=n || y>=m){
			break;
		}
	}
	dsdic++;
}
 
inline ll getCS(int col,int st,int ed){
	if(st>ed){
		swap(st,ed);
	}
	
	return colsum[col][ed]-(st==0?0:colsum[col][st-1]);
}
 
//inline int getDSUId(int x,int y){
//	return dsuid[x][y];
//}
//
//inline int getDSUInd(int x,int y){
//	return dsuind[x][y];
//}
//
//inline int getDSDId(int x,int y){
//	return dsdid[x][y];
//}
//
//inline int getDSDInd(int x,int y){
//	return dsdind[x][y];
//}
 
inline ll getDSU(int id,int st,int ed){
	if(st>ed){
		swap(st,ed);
	}
	
	return dsusum[id][ed]-(st==0?0:dsusum[id][st-1]);
}
 
inline ll getDSD(int id,int st,int ed){
	if(st>ed){
		swap(st,ed);
	}
	
	return dsdsum[id][ed]-(st==0?0:dsdsum[id][st-1]);
}
 
inline ll getDSU(int x1,int y1,int x2,int y2){
	dbg cout<<"DSU="<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<dsuid[x1][y1]<<" "<<dsuid[x2][y2]<<endl;
	
	assert(dsuid[x1][y1]==dsuid[x2][y2]);
	return getDSU(dsuid[x1][y1],dsuind[x1][y1],dsuind[x2][y2]);
}
inline ll getDSD(int x1,int y1,int x2,int y2){
	dbg cout<<"DSD="<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<dsdid[x1][y1]<<" "<<dsdid[x2][y2]<<endl;
	assert(dsdid[x1][y1]==dsdid[x2][y2]);
	return getDSD(dsdid[x1][y1],dsdind[x1][y1],dsdind[x2][y2]);
}
 
inline ll getRS(int rownum,int l,int r){
	if(l>r){
		swap(l,r);
	}
	
	return rowsum[rownum][r]-(l==0?0:rowsum[rownum][l-1]);
}
 
void proceedL(){
	
	for(int i=k-1;i<=n-k;i++){
		int up=k-1;
		for(int j=0;j<k;j++){
			tri[L][i][k-1]+=getCS(k-1-j,i-up,i+up);
			up--;
		}
	}
	
	
	for(int i=k-1;i<=n-k;i++){
		dbg cout<<"Doing line "<<i<<endl;
		for(int j=k;j<=m-k;j++){
			dbg cout<<"Solving for column "<<j<<endl;
			
			ll p1=tri[L][i][j-1];
			ll p2=getCS(j,i-k+1,i+k-1);
			ll p3=getDSU(i,j-k,i-k+1,j-1);
			ll p4=getDSD(i,j-k,i+k-1,j-1);
			ll p5=a[i][j-k];
			
			dbg cout<<i<<" "<<j<<" p="<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" "<<p5<<endl;
			tri[L][i][j]=p1+p2-p3-p4+p5;
		}
		
	}
	
//	dbg{
		ll mx=0; 
		for(int i=k-1;i<=n-k;i++){
			for(int j=k-1;j<=m-k;j++){
				mx=max(mx,tri[L][i][j]);
			}
		}
		cout<<mx<<endl;
		exit(0);
//	}
}
 
void proceedR(){
	
	for(int i=k-1;i<=n-k;i++){
		int up=k-1;
		for(int j=0;j<k;j++){
			tri[R][i][k-1]+=getCS(k-1+j,i-up,i+up);
			up--;
		}
	}
	
	
	for(int i=k-1;i<=n-k;i++){
		dbg cout<<"Doing line "<<i<<endl;
		for(int j=k;j<=m-k;j++){
			dbg cout<<"Solving for column "<<j<<endl;
			
			ll p1=tri[R][i][j-1];
			ll p2=getCS(j-1,i-k+1,i+k-1);
			ll p3=getDSD(i,j+k-1,i-k+1,j);
			ll p4=getDSU(i,j+k-1,i+k-1,j);
			ll p5=a[i][j+k-1];
			
			dbg cout<<i<<" "<<j<<" p="<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" "<<p5<<endl;
			tri[R][i][j]=p1-p2+p3+p4-p5;
		}
		
	}
	
	dbg{
		for(int i=k-1;i<=n-k;i++){
			for(int j=k-1;j<=m-k;j++){
				cout<<tri[R][i][j]<<" ";
			}
			cout<<endl;
		}
	}
}
 
int main(int argc,char* argv[]){
	qi;
	cin>>n>>m>>k;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	
	//calc for the col sum
	for(int i=0;i<m;i++){
		colsum[i][0]=a[0][i];
		for(int j=1;j<n;j++){
			colsum[i][j]=colsum[i][j-1]+a[j][i];
		}
	}
	
	for(int i=0;i<n;i++){
		rowsum[i][0]=a[i][0];
		for(int j=1;j<m;j++){
			rowsum[i][j]=rowsum[i][j-1]+a[i][j];
		}
	}
	
	//calc for the dsu
	for(int i=0;i<n;i++){
		runDsu(i,0);
	}
	for(int i=1;i<m;i++){
		runDsu(n-1,i);
	}
	
	dbg{
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				printf("(%d,%d) in dsu %d ind= %d sum_until=%d\t",i,j,dsuid[i][j],dsuind[i][j],dsusum[dsuid[i][j]][dsuind[i][j]]);
			}
			printf("\n");
		}
	}
	
	//calc for dsd
	for(int i=n-1;i>=0;i--){
		runDsd(i,0);
	}
	for(int i=1;i<m;i++){
		runDsd(0,i);
	}
	
	dbg{
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				printf("(%d,%d) in dsd %d ind= %d sum_until=%d\t",i,j,dsdid[i][j],dsdind[i][j],dsdsum[dsdid[i][j]][dsdind[i][j]]);
			}
			printf("\n");
		}
	}
	
	proceedL();
	proceedR();
	
	//calc left up corner answer
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
//			cout<<i<<' '<<j<<" "<<a[i][j]<<" "<<max(0,k-abs(i-(k-1))-abs(j-(k-1)))<<endl;
			f[k-1][k-1]+=a[i][j]*max(0ll,k-abs(i-(k-1))-abs(j-(k-1)));
		}
	}
	
	dbg cout<<"ini="<<f[k-1][k-1]<<endl;
	
	//move to the right
	for(int i=k-1;i<=n-k;i++){
		for(int j=k;j<=m-k;j++){
			//move
			ll p1=f[i][j-1];
			ll p2=tri[R][i][j];
			ll p3=tri[L][i][j-1];
			
			dbg cout<<"F "<<i<<" "<<j<<"="<<p1<<"+"<<p2<<"-"<<p3<<endl;
			f[i][j]=p1+p2-p3;
		}
		
		//move down
		if(i==n-k){
			continue;
		}
		
		ll upt=0,downt=0;
		
		int up=k-1;
		for(int j=i;j>=i-k+1;j--){
			upt+=getRS(j,k-1-up,k-1+up);
			up--;
		}
		
		int down=k-1;
		for(int j=i+1;j<=i+k;j++){
			downt+=getRS(j,k-1-down,k-1+down);
			down--;
		}
		
		dbg cout<<"F:"<<i+1<<" "<<k-1<<"="<<f[i][k-1]<<" "<<upt<<" "<<downt<<endl;
		
		
		f[i+1][k-1]=f[i][k-1]-upt+downt;	
		
	}
	
	int x=k-1,y=k-1;
	for(int i=k-1;i<=n-k;i++){
		for(int j=k-1;j<=m-k;j++){
			if(f[i][j]>f[x][y]){
				x=i;
				y=j;
			}
		}
	}
	
	cout<<x+1<<" "<<y+1<<endl;
	return 0;
}
 
Main.cpp: In function ‘int main(int, char**)’:
Main.cpp:268:117: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘long long int’ [-Wformat=]
     printf("(%d,%d) in dsu %d ind= %d sum_until=%d\t",i,j,dsuid[i][j],dsuind[i][j],dsusum[dsuid[i][j]][dsuind[i][j]]);
                                                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
Main.cpp:285:117: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘long long int’ [-Wformat=]
     printf("(%d,%d) in dsd %d ind= %d sum_until=%d\t",i,j,dsdid[i][j],dsdind[i][j],dsdsum[dsdid[i][j]][dsdind[i][j]]);
                                                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^