(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #78707

#제출 시각아이디문제언어결과실행 시간메모리
78707tincamatei자리 배치 (IOI18_seats)C++14
100 / 100
2145 ms151180 KiB
#pragma GCC target("avx,avx2,sse,sse2") #pragma GCC optimize("Ofast") #include "seats.h" #include <bits/stdc++.h> using namespace std; const int MAX_N = 1000000; int val[1+4*MAX_N], fr[1+4*MAX_N]; int lazy[1+4*MAX_N]; int initsum[MAX_N+1]; static inline void pushLazy(int nod, int l, int r) { if(lazy[nod] != 0) { val[nod] += lazy[nod]; if(l < r) { lazy[2 * nod] += lazy[nod]; lazy[2 * nod + 1] += lazy[nod]; } lazy[nod] = 0; } } inline void init(int l, int r, int nod = 1) { if(l == r) { val[nod] = initsum[l]; fr[nod] = 1; } else if(l < r){ int mid = (l + r) / 2; init(l, mid, 2 * nod); init(mid + 1, r, 2 * nod + 1); val[nod] = min(val[2 * nod], val[2 * nod + 1]); if(val[2 * nod] == val[nod]) fr[nod] += fr[2 * nod]; if(val[2 * nod + 1] == val[nod]) fr[nod] += fr[2 * nod + 1]; } } inline void update(int i, int j, int valU, int l, int r, int nod = 1) { pushLazy(nod, l, r); if(r < i || j < l) return; int mid = (l + r) / 2; if(i <= l && r <= j) { lazy[nod] += valU; pushLazy(nod, l, r); return; } update(i, j, valU, l, mid, 2 * nod); update(i, j, valU, mid + 1, r, 2 * nod + 1); val[nod] = val[2 * nod], fr[nod] = fr[2 * nod]; if(val[2 * nod + 1] < val[nod]) { val[nod] = val[2 * nod + 1]; fr[nod] = fr[2 * nod + 1]; } else if(val[nod] == val[2 * nod + 1]) fr[nod] += fr[2 * nod + 1]; } int N, H, W; int cells[4]; vector<vector<int> > matr; vector<int> R, C; static inline void activateSqr(int l, int c, int x) { cells[0] = matr[l][c]; cells[1] = matr[l + 1][c]; cells[2] = matr[l][c + 1]; cells[3] = matr[l + 1][c + 1]; std::sort(cells, cells + 4); update(cells[0], cells[1] - 1, x, 0, N - 1); update(cells[2], cells[3] - 1, 4 * x, 0, N - 1); } void give_initial_chart(int H, int W, std::vector<int> _R, std::vector<int> _C) { N = H * W; R = _R; C = _C; matr.resize(H+2, vector<int>(W+2, N)); for(int i = 0; i < N; ++i) { R[i]++; C[i]++; matr[R[i]][C[i]] = i; } for(int i = 0; i <= H; ++i) for(int j = 0; j <= W; ++j) { cells[0] = matr[i][j]; cells[1] = matr[i + 1][j]; cells[2] = matr[i][j + 1]; cells[3] = matr[i + 1][j + 1]; std::sort(cells, cells + 4); initsum[cells[0]]++; initsum[cells[1]]--; initsum[cells[2]]+=4; initsum[cells[3]]-=4; } for(int i = 1; i < N; ++i) initsum[i] += initsum[i - 1]; init(0, N - 1, 1); } int dr[] = {0,-1, 0, -1}; int dc[] = {0, 0,-1, -1}; int swap_seats(int a, int b) { vector<pair<int, int> > yeet; for(int i = 0; i < 4; ++i) { yeet.push_back(make_pair(R[a] + dr[i], C[a] + dc[i])); yeet.push_back(make_pair(R[b] + dr[i], C[b] + dc[i])); } std::sort(yeet.begin(), yeet.end()); yeet.resize(unique(yeet.begin(), yeet.end()) - yeet.begin()); for(int i = 0; i < yeet.size(); ++i) activateSqr(yeet[i].first, yeet[i].second, -1); swap(R[a], R[b]); swap(C[a], C[b]); swap(matr[R[a]][C[a]], matr[R[b]][C[b]]); for(int i = 0; i < yeet.size(); ++i) activateSqr(yeet[i].first, yeet[i].second, 1); if(val[1] != 4) return 0; return fr[1]; }

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

seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:119:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < yeet.size(); ++i)
                 ~~^~~~~~~~~~~~~
seats.cpp:124:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < yeet.size(); ++i)
                 ~~^~~~~~~~~~~~~
#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...