제출 #1012104

#제출 시각아이디문제언어결과실행 시간메모리
1012104Do_you_copyKrave (COI14_krave)C++17
100 / 100
386 ms80316 KiB
#include <bits/stdc++.h> //#define int long long #define fi first #define se second #define pb push_back #define faster ios_base::sync_with_stdio(0); cin.tie(0); using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair <int, int>; using pil = pair <int, ll>; using pli = pair <ll, int>; using pll = pair <ll, ll>; mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count()); ll min(const ll &a, const ll &b){ return (a < b) ? a : b; } ll max(const ll &a, const ll &b){ return (a > b) ? a : b; } //const ll Mod = 1000000007; //const ll Mod2 = 999999999989; const int inf = 1e9; //only use when required const int maxN = 1e5 + 1; int n, a, b; pair <int, int> getBound(int x, set <int> &S){ int resl = 0, resr = inf; auto it = S.lower_bound(x); if (it != S.end()) resr = *it; if (it != S.begin()){ --it; resl = *it; } return {resl, resr}; } struct SegmentTree{ vector <set <int>> st; SegmentTree(){ st.resize(4 * maxN); } SegmentTree(int _n){ st.resize(4 * _n); st[1].insert(0); } void update(int id, int i, int j, int x, int l, int r){ if (i > r || j < l) return; // cerr << i << " " << j << " " << x << " " << l << " " << r << "?\n"; if (i <= l && r <= j){ st[id].insert(x); return; } int mid = (l + r) >> 1; update(id << 1, i, j, x, l, mid); update(id << 1 | 1, i, j, x, mid + 1, r); } pair <int, int> get(int id, int i, int j, int l, int r){ if (i > r || i < l) return {0, inf}; if (l == r){ return getBound(j, st[id]); } int mid = (l + r) >> 1; pair <int, int> L = get(id << 1, i, j, l, mid); pair <int, int> R = get(id << 1 | 1, i, j, mid + 1, r); pair <int, int> M = getBound(j, st[id]); return {max({L.fi, R.fi, M.fi}), min({L.se, R.se, M.se})}; } }; void Init(){ cin >> a >> b >> n; SegmentTree sta(a); SegmentTree stb(b); sta.st[1].insert(b); stb.st[1].insert(a); for (int i = 1; i <= n; ++i){ int x, y, d; cin >> x >> y >> d; auto [lb, rb] = sta.get(1, x, y, 1, a); auto [la, ra] = stb.get(1, y, x, 1, b); // cerr << la << " " << ra << " " << lb << " " << rb << "\n"; if (d == 1){ ll res1 = 1LL * (ra - la) * (y - lb); ll res2 = 1LL * (ra - la) * (rb - y); cout << min(res1, res2) << " " << max(res1, res2) << "\n"; sta.update(1, la + 1, ra, y, 1, a); } else{ ll res1 = 1LL * (rb - lb) * (x - la); ll res2 = 1LL * (rb - lb) * (ra - x); cout << min(res1, res2) << " " << max(res1, res2) << "\n"; stb.update(1, lb + 1, rb, x, 1, b); } } } #define taskname "test" signed main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } faster; ll tt = 1; //cin >> tt; while (tt--){ Init(); } if (fopen("timeout.txt", "r")){ ofstream timeout("timeout.txt"); timeout << 1000 * double(clock()) / CLOCKS_PER_SEC; #ifndef debug cerr << "\nTime elapsed: " << 1000 * double(clock()) / CLOCKS_PER_SEC << "ms\n"; #endif } }

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

krave.cpp: In function 'int main()':
krave.cpp:106:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
krave.cpp:107:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  107 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...