제출 #538202

#제출 시각아이디문제언어결과실행 시간메모리
538202idasCutting a rectangle (LMIO18_staciakampis)C++11
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr) #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) #define TSTS int ttt; cin >> ttt; while(ttt--) solve() #define all(x) (x).begin(), (x).end() #define le(vec) vec[vec.size()-1] #define sz(x) ((int)((x).size())) #define pb push_back #define s second #define f first using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef map<int, int> mii; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long double, long double> pdd; const int INF=1e9, MOD=1e9+7, mod=998244353; const ll LINF=1e13; void setIO() { FAST_IO; } void setIO(string s) { FAST_IO; freopen((s+".in").c_str(), "r", stdin); //freopen((s+".out").c_str(), "w", stdout); } //1) go through all initial L both on higher side //2) go through all initial L on lower side const int N=1e5+10, M=5e6+10; int n, a[N], b[N]; vector<pii> inf; bool v[M]; bool can(int x, int y, int vis) { FOR(i, 1, n) { if(i==vis) continue; if(a[i]==x){ y-=b[i]; } else if(a[i]==y){ x-=b[i]; } else{ return false; } } return true; } int main() { setIO(); cin >> n; ll area=0; FOR(i, 0, n) { cin >> a[i] >> b[i]; area+=a[i]*b[i]; inf.pb({a[i],b[i]}); } sort(all(inf), greater<pii>()); FOR(i, 0, n) a[i]=inf[i].f, b[i]=inf[i].s; set<int> ans; FOR(i, 1, n) { int x=a[i], y=a[0]-b[i]; if((a[i]+b[0])*(a[0])==area){ if(can(x, y, i)){ ans.insert(min(a[i]+b[0], a[0])); } } x=a[i]-b[0]; y=a[0]; if((a[i])*(a[0]+b[i])==area){ if(can(x, y, i)){ ans.insert(min(a[i], a[0]+b[i])); } } } FOR(i, 1, n) { if(v[b[i]]) continue; v[b[i]]=true; int x=b[i]-b[0], y=a[0]; if((b[i])*(a[0]+a[i])==area){ if(can(x, y, i)){ ans.insert(b[i]); } } x=b[i]; y=a[0]-a[i]; if((b[i]+b[0])*a[0]==area){ if(can(x, y, i)){ ans.insert(min(b[i]+b[0], a[0])); } } } int cur=b[0]; bool bad=false; FOR(i, 1, n) { if(a[i]!=cur && b[i]!=cur){ bad=true; } } if(!bad){ ans.insert(cur); } cout << sz(ans) << "\n"; for(auto x : ans){ cout << x << "\n"; } }

컴파일 시 표준 에러 (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);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...