제출 #1304422

#제출 시각아이디문제언어결과실행 시간메모리
1304422BilAktauAlmansurCutting a Rectangle (BOI24_rectangle)C++20
25 / 100
2113 ms481988 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second const int N = 3e5 + 7, M = 5e6 + 7, mod = 1e9 + 7; int n; pair<int, int> p[N]; multiset<int> ga[M], gb[M]; void solve() { cin>>n; int area = 0; for(int i = 1; i <= n; i++) { cin>>p[i].fi>>p[i].se; area = area + p[i].fi * p[i].se; } vector<int> ans; for(int i = 1; i <= 5e6; i++) { if(area % i == 0 && i <= area / i) { int x = area / i, y = i; vector<int> us(n + 1, 0); for(int j = 1; j <= n; j++) { ga[p[j].fi].clear(); gb[p[j].se].clear(); } for(int j = 1; j <= n; j++) { ga[p[j].fi].insert(j); gb[p[j].se].insert(j); } while(x && y) { if(x < y)swap(x, y); int ok = 0; if(x <= 5e6) { for(auto i : ga[x]) { y -= p[i].se; ok = i; break; } } if(ok) { ga[p[ok].fi].erase(ga[p[ok].fi].find(ok)); gb[p[ok].se].erase(gb[p[ok].se].find(ok)); continue; } for(auto i : gb[y]) { x -= p[i].fi; ok = i; break; } if(ok) { ga[p[ok].fi].erase(ga[p[ok].fi].find(ok)); gb[p[ok].se].erase(gb[p[ok].se].find(ok)); continue; } for(auto i : ga[y]) { x -= p[i].se; ok = i; break; } if(ok) { ga[p[ok].fi].erase(ga[p[ok].fi].find(ok)); gb[p[ok].se].erase(gb[p[ok].se].find(ok)); continue; }else break; } if(!x || !y)ans.push_back(i); } } cout << ans.size() << '\n'; for(auto i : ans)cout << i << '\n'; } signed main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); int T = 1; // cin>>T; while(T --)solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...