제출 #1304445

#제출 시각아이디문제언어결과실행 시간메모리
1304445_TemirhanCutting a Rectangle (BOI24_rectangle)C++20
0 / 100
2 ms572 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>  
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#if defined(__GNUC__) || defined(__clang__)
#pragma GCC optimize("Ofast,unroll-loops,inline-functions,no-stack-protector")
#pragma GCC target("avx2,fma,tune=native")
#pragma clang loop vectorize(enable)
#pragma clang loop interleave(enable)
#endif

#define int long long
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define nl '\n'
#define o_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int, int> pii;

void file( string s = "" )
{
    if( s.empty() )
        return;
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

const int N = 2e5 + 2;
const int N1 = 1e6 + 2;
const int inf = 1e9 + 2;
const int INF = 1e18 + 2;
const int mod = 1e9 + 7;
int T = 1;

void solve()
{
    int n;
    cin >>n;
    set< pii > st;
    for( int i = 1, l, w; i <= n; ++i )
    {
        cin >>l >>w;
        if( i == 1 )
        {
            st.insert({l, w});
            continue;
        }
        set< pii > _st;
        for( auto [l1, w1]: st )
        {
            if( l == l1 )
                _st.insert({min(l, w + w1), max(l, w + w1)});
            if( w == w1 )
                _st.insert({min(l + l1, w), max(l + l1, w)});
            if( l == w1 )
                _st.insert({min(l, l1 + w), max(l, l1 + w)});
            if( w == l1 )
                _st.insert({min(w, l + w1), max(w, l + w1)});
        }
        st.swap(_st);
    }
    set< int > ans;
    for( auto [l, w]: st )
        ans.insert(min(l, w));
    cout <<sz(ans) <<nl;
    for( int l: ans )
        cout <<l <<nl;
}

signed main()
{
    file("");
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin >>T;
    while( T-- )
        solve();
}

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

Main.cpp: In function 'void file(std::string)':
Main.cpp:29:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...