Submission #537477

#TimeUsernameProblemLanguageResultExecution timeMemory
537477idasCutting a rectangle (LMIO18_staciakampis)C++11
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr) #define f first #define s second #define pb push_back #define sz(x) ((int)((x).size())) #define le(vec) vec[vec.size()-1] #define all(x) (x).begin(), (x).end() #define TSTS int ttt; cin >> ttt; while(ttt--) solve() using namespace std; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long double, long double> pdd; typedef map<int, int> mii; typedef vector<int> vi; typedef long double ld; typedef long long ll; const int INF=1e9, MOD=1e9+7, mod=998244353; const ll LINF=1e18; void setIO() { FAST_IO; } void setIO(string s) { FAST_IO; freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } const int N=1e5+10; int n, a[N], b[N]; vector<pii> inf; set<int> ans; bool can(int x, int y) { FOR(i, 2, n) { if(a[i]==x){ y-=b[i]; } else if(a[i]==y){ x-=b[i]; } else{ return false; } } if(x==0 || y==0) return true; else return false; } int main() { setIO(); cin >> n; FOR(i, 0, n) { int aa, bb; cin >> aa >> bb; inf.pb({aa,bb}); } sort(all(inf), greater<pii>()); FOR(i, 0, n) { a[i]=inf[i].f; b[i]=inf[i].s; } // int x=a[1], y=a[0]-b[1]; // if(can(x, y)){ // ans.insert(min(a[1]+b[0], a[0])); // } // // x=a[0]; y=a[1]-b[0]; // if(can(x, y)){ // ans.insert(min(a[1], a[0]+b[1])); // } int x=a[0]-a[1], y=b[1]; if(can(x, y)){ ans.insert(min(a[0], b[0]+b[1])); } bool ok=true; int sm=b[0]; FOR(i, 1, n) { if(a[i]!=sm && b[i]!=sm){ ok=false; break; } } if(ok) ans.insert(sm); cout << sz(ans) << "\n"; for(auto x : ans){ cout << x << "\n"; } }

Compilation message (stderr)

staciakampis.cpp: In function 'void setIO(std::string)':
staciakampis.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
staciakampis.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     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...