Submission #278871

#TimeUsernameProblemLanguageResultExecution timeMemory
278871shrek12357Dominance (CEOI08_dominance)C++14
100 / 100
35 ms768 KiB
#include <bits/stdc++.h> #define eb emplace_back #define sz(V) ((int)(V).size()) #define allv(V) ((V).begin()),((V).end()) #define sorv(V) sort(allv(V)) #define univ(V) (V).erase(unique(allv(V)),(V).end()) #define upmin(a,b) (a)=min((a),(b)) #define INF (0x3f3f3f3f) #define INFLL (0x3f3f3f3f3f3f3f3fll) using namespace std; typedef long long ll; typedef pair<int, int> pii; vector<pii> EV[6005]; int S[2][6005]; int SY[3005], EY[3005], SX[3005], EX[3005]; int A[3005], B[3005], C[3005]; bitset<3005> D; ll AnsW, AnsB; int N; void process() { vector<int> YV, XV; for(int i = 0; i < N; i++) { EY[i]++; EX[i]++; YV.eb(SY[i]); YV.eb(EY[i]); XV.eb(SX[i]); XV.eb(EX[i]); } sorv(YV); univ(YV); sorv(XV); univ(XV); for(int i = 0; i < N; i++) { SY[i] = int(lower_bound(allv(YV), SY[i]) - YV.begin()); EY[i] = int(lower_bound(allv(YV), EY[i]) - YV.begin()); SX[i] = int(lower_bound(allv(XV), SX[i]) - XV.begin()); EX[i] = int(lower_bound(allv(XV), EX[i]) - XV.begin()); EV[SY[i]].eb(SX[i], D[i] ? 1 : -1); EV[SY[i]].eb(EX[i], D[i] ? -1 : 1); EV[EY[i]].eb(SX[i], D[i] ? -1 : 1); EV[EY[i]].eb(EX[i], D[i] ? 1 : -1); } int yn = sz(YV), xn = sz(XV); memset(S[1], 0, (xn+2)<<2); for(int y = 0; y < yn; y++) { memcpy(S[0], S[1], (xn+2)<<2); memset(S[1], 0, (xn+2)<<2); for(auto &ev : EV[y]) S[1][ev.first] += ev.second; for(int x = 1; x < xn; x++) S[1][x] += S[1][x-1]; for(int x = 0; x < xn; x++) { S[1][x] += S[0][x]; if(S[1][x]) { ll area = ll(YV[y+1]-YV[y]) * (XV[x+1]-XV[x]); (0 < S[1][x] ? AnsW : AnsB) += area; } } EV[y].clear(); } } int main() { scanf("%*d%*d%d", &N); for(int i = 0; i < N; i++) { char c; scanf(" %c%d%d%d", &c, &A[i], &B[i], &C[i]); D[i] = 'W' == c; } for(int i = 0; i < N; i++) { SY[i] = A[i] - C[i] - B[i]; EY[i] = A[i] + C[i] - B[i]; SX[i] = A[i] + B[i] - C[i]; EX[i] = A[i] + B[i] + C[i]; SY[i] = (SY[i] < 0 ? SY[i] : SY[i]+1) / 2; SX[i] = (SX[i] < 0 ? SX[i] : SX[i]+1) / 2; EY[i] = (EY[i] < 0 ? EY[i]-1 : EY[i]) / 2; EX[i] = (EX[i] < 0 ? EX[i]-1 : EX[i]) / 2; } process(); for(int i = 0; i < N; i++) { SY[i] = A[i] - C[i] - B[i]; EY[i] = A[i] + C[i] - B[i]; SX[i] = A[i] + B[i] - C[i]; EX[i] = A[i] + B[i] + C[i]; SY[i] = (SY[i] < 0 ? SY[i]-1 : SY[i]) / 2; SX[i] = (SX[i] < 0 ? SX[i]-1 : SX[i]) / 2; EY[i] = (EY[i] < 0 ? EY[i] : EY[i]+1) / 2 - 1; EX[i] = (EX[i] < 0 ? EX[i] : EX[i]+1) / 2 - 1; } process(); cout << AnsW << " " << AnsB << endl; return 0; }

Compilation message (stderr)

dominance.cpp: In function 'int main()':
dominance.cpp:66:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   66 |  scanf("%*d%*d%d", &N);
      |  ~~~~~^~~~~~~~~~~~~~~~
dominance.cpp:69:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   69 |   scanf(" %c%d%d%d", &c, &A[i], &B[i], &C[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...