제출 #1304395

#제출 시각아이디문제언어결과실행 시간메모리
1304395BilAktauAlmansurCutting a Rectangle (BOI24_rectangle)C++20
0 / 100
16 ms572 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
const int N = 3e5 + 7, mod = 1e9 + 7;

int n;
pair<int, int> p[N];
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) {
            set<pair<int, int> > v;
            v.insert({area / i, i});
            // cout << area / i << ' ' << i << '\n';
            for(int j = n; j >= 1; j--) {
                set<pair<int, int> > nv;
                for(auto [x, y] : v) {
                    if(x == p[j].fi) {
                        nv.insert({max(y - p[j].se, x), min(y - p[j].se, x)});
                    }
                    if(y == p[j].fi) {
                        nv.insert({max(x - p[j].se, y), min(x - p[j].se, y)});
                    }
                    if(x == p[j].se) {
                        nv.insert({max(y - p[j].fi, x), min(y - p[j].fi, x)});
                    }
                    if(y == p[j].se) {
                        nv.insert({max(x - p[j].fi, y), min(x - p[j].fi, y)});
                    }
                }
                v = nv;
            }
            if(v.size()) {
                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...