ä¸è¦ããã¨å ¸åçãªã座æ¨å§ç¸®ã+ãäºæ¬¡å ãããæ³ããªã®ã ããããã 㨠TLE / MLE ãã¦ãã¾ãã
åé¡æ¦è¦
ã®ã°ãªããä¸ã« æã®é·æ¹å½¢ã®ç´ãæ·ãã¦ããã æç®ã®ç´ã¯
ãæºããåº§æ¨ ãè¦ãé åã«é ç½®ããããæãå¤ãã®ç´ãéãªã£ã¦ãããã¹ã§ã¯ä½æéãªã£ã¦ããããããã³ããã®ãããªãã¹ãä½ãã¹ããã®ããæ°ãä¸ããã
å¶ç´
èãããã¨
ããã«ã
- 座æ¨å§ç¸®ãããã¨ã§ã ç¨åº¦ã®ã°ãªããã ã¨ã¿ãªãã¦
- äºæ¬¡å ãããæ³ããã
ã¨ããåé¡ã«è¦ããããããããã ã¨ã ã®è¨ç®éã¨ãªã£ã¦ãTLE ãããã MLE ãããããã ã ã¨ããå¶ç´ã絶å¦ã£ã½ãã
ä¸æä¸æã®é·æ¹å½¢ãå°ãã
ããã§å¥ã®ä½æ¦ãç«ã¦ãããä»åã¯å¶ç´æ¡ä»¶ããã1 æ 1 æã®é·æ¹å½¢ã®ç´ã®å¤§ãããæ大ã§ã ç¨åº¦ã®ããã ããã£ã¦ãé·æ¹å½¢ã®ç´ãè¦ãé åã 1 ãã¹ãã¤æç´ã«ã«ã¦ã³ããã¦ãã£ã¦ããã座æ¨å§ç¸®ãªãã¦è¦ããªãã£ãã
ãã ã ã®é åãã¡ã¢ãªã«ããããããã«ã¯ãããªãã®ã§ãå¿ è¦ãªã¨ããã ãã¡ã¢ãªã«ãããããå ·ä½çã«ã¯ std::map ãªã©ã®å»é é åãç¨ããã° OKã
std::map ãç¨ããå ´åã ç¨åº¦ã¨ãã¦ãè¨ç®é㯠ã¨ãªãã
ã³ã¼ã
#include <bits/stdc++.h> using namespace std; using pint = pair<int,int>; #define REP(i, n) for (long long i = 0; i < (long long)(n); ++i) #define REP2(i, a, b) for (long long i = a; i < (long long)(b); ++i) int main() { int N, H, W; cin >> N >> H >> W; map<pint,int> fi; REP(i, N) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; --x1, --y1; REP2(x, x1, x2) REP2(y, y1, y2) fi[pint(x, y)]++; } int res = 0, area = 0; for (auto it : fi) { if (res < it.second) res = it.second, area = 1; else if (res == it.second) ++area; } cout << res << endl << area << endl; }