2542021-03-06 16:39:42mraronSivatagcpp14Elfogadva 40/4046ms24804 KiB
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

using ll = long long;
using ull = unsigned long long ;
using ld = long double ;
using str = string;
using ordered_set=tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)
#define int ll
int t[1002][1002];
main() {
	IO;
	int n,m,k,q;
	cin>>n>>m>>k>>q;
	for(int i=0;i<q;++i) {
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		t[a][b]++;
		t[c+1][b]--;
		t[a][d+1]--;
		t[c+1][d+1]++;
	}
	
	for(int i=0;i<=n;++i) {
		for(int j=0;j<=m;++j) {
			if(i)t[i][j]+=t[i-1][j];
			if(j)t[i][j]+=t[i][j-1];
			if(i&&j)t[i][j]-=t[i-1][j-1];
		}
	}
	
	for(int i=0;i<=n;++i) {
		for(int j=0;j<=m;++j) {
			if(i)t[i][j]+=t[i-1][j];
			if(j)t[i][j]+=t[i][j-1];
			if(i&&j)t[i][j]-=t[i-1][j-1];
		}
	}
	
	int ans=-1;
	pair<int,int> pos;
	for(int i=1;i+k-1<=n;++i) {
		for(int j=1;j+k-1<=m;++j) {
			int cans=t[i+k-1][j+k-1]-t[i-1][j+k-1]-t[i+k-1][j-1]+t[i-1][j-1];
			if(ans<cans) {
				ans=cans;
				pos={i,j};
			}
		}
	}
	
	cout<<ans<<"\n";
	cout<<pos.xx<<" "<<pos.yy<<"\n";	
	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/02ms1848 KiB
2Elfogadva0/043ms11168 KiB
3Elfogadva2/22ms4248 KiB
4Elfogadva2/23ms6304 KiB
5Elfogadva2/28ms11160 KiB
6Elfogadva2/28ms11272 KiB
7Elfogadva2/28ms11164 KiB
8Elfogadva2/28ms11172 KiB
9Elfogadva2/22ms4276 KiB
10Elfogadva2/23ms6320 KiB
11Elfogadva2/28ms11184 KiB
12Elfogadva2/28ms11180 KiB
13Elfogadva2/28ms11196 KiB
14Elfogadva2/28ms11188 KiB
15Elfogadva1/137ms8688 KiB
16Elfogadva1/137ms11944 KiB
17Elfogadva1/119ms14732 KiB
18Elfogadva1/132ms15960 KiB
19Elfogadva2/243ms17400 KiB
20Elfogadva2/243ms18884 KiB
21Elfogadva2/241ms20368 KiB
22Elfogadva2/241ms21844 KiB
23Elfogadva2/246ms23324 KiB
24Elfogadva2/245ms24804 KiB