제출 #1304416

#제출 시각아이디문제언어결과실행 시간메모리
1304416BilAktauAlmansurCutting a Rectangle (BOI24_rectangle)C++20
25 / 100
2091 ms8916 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]; vector<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; ga[p[i].fi].push_back(i); gb[p[i].se].push_back(i); 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); while(x && y) { if(x < y)swap(x, y); bool ok = 0; if(x <= 5e6) { for(auto i : ga[x]) { if(!us[i]) { us[i] = 1; y -= p[i].se; ok = 1; break; } } } if(ok)continue; for(auto i : gb[y]) { if(!us[i]) { us[i] = 1; x -= p[i].fi; ok = 1; break; } } if(ok)continue; if(x <= 5e6) { for(auto i : gb[x]) { if(!us[i]) { us[i] = 1; y -= p[i].fi; ok = 1; break; } } } if(ok)continue; for(auto i : ga[y]) { if(!us[i]) { us[i] = 1; x -= p[i].se; ok = 1; break; } } if(!ok)break; } bool ok = 1; for(int j = 1; j <= n; j++) if(!us[j])ok = 0; if((!x || !y) && ok)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...