제출 #963569

#제출 시각아이디문제언어결과실행 시간메모리
963569Trisanu_DasGarden (JOI23_garden)C++17
30 / 100
3033 ms35152 KiB
#include <bits/stdc++.h>
#define fi first
#define se second
#define ssize(x) int(x.size())
#define pn printf("\n");
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int inf = 2e09; ll infll = 2e18; int mod = 119<<23|1;
void answer(){
		int n, m, d;
		scanf("%d%d%d", &n, &m, &d);
		vector<vector<int>> t(d*2);
		for(int i = 1; i <= n; ++i){
				int a, b; scanf("%d%d", &a, &b);
				t[a].emplace_back(b), t[a+d].emplace_back(b);
		}
		for(int i = 0; i < d*2; ++i) sort(t[i].begin(), t[i].end());
		
		vector<vector<int>> x(d*2);
		vector<int> y(m+1);
		for(int i = 1; i <= m; ++i){
				int a, b; scanf("%d%d", &a, &b), y[i] = b;
				x[a].emplace_back(i), x[a+d].emplace_back(i);
		}
		int result = inf;
		for(int i = 0; i < d; ++i){
				multiset<int> a, b;
				for(int j = 0; j < d; ++j) for(int &u : x[j]) b.emplace(y[u]);
				for(int j = i; j < i+d; ++j){
						int cnt = 0;
						for(int &u : t[j]) a.emplace(u), ++cnt;
						for(int &u : x[j]) b.erase(b.lower_bound(y[u])), ++cnt;
						if(ssize(a) != n || !cnt) continue;
						int mxa = *prev(a.end()), mxb = ssize(b) ? *prev(b.end()) : 0;
						for(int l = 0; l < d; ++l){
								if(!ssize(b)) mxb = l;
								result = min(result, (j-i+1)*(max(mxa, mxb)-l+1));
								auto it = a.lower_bound(l);
								if(it != a.end() && *it == l) mxa = max(mxa, l+d);
								it = b.lower_bound(l);
								if(it != b.end() && *it == l) mxb = max(mxb, l+d);
						}
				}
		}
		printf("%d\n", result);
}
signed main(){
		int T = 1;
		for(++T; --T; ) answer();
		return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

garden.cpp: In function 'void answer()':
garden.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d%d%d", &n, &m, &d);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
garden.cpp:15:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     int a, b; scanf("%d%d", &a, &b);
      |               ~~~~~^~~~~~~~~~~~~~~~
garden.cpp:23:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     int a, b; scanf("%d%d", &a, &b), y[i] = b;
      |               ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...