Submission #516651

#TimeUsernameProblemLanguageResultExecution timeMemory
516651Tox123Cutting a rectangle (LMIO18_staciakampis)C++17
0 / 100
1 ms204 KiB
#include <iostream> #include <list> #include <vector> #include <algorithm> using namespace std; int main(){ int n; cin >> n; vector<pair<int, int>> PossibleR; for(int i = 0;i<n;i++){ int a, b; cin >> a >> b; int CurrentPossibleRSize = static_cast<int>(PossibleR.size()); if(CurrentPossibleRSize==0){ PossibleR.push_back(make_pair(a,b)); continue; } vector<pair<int, int>> OtherPossibleR; for(int x = 0;x < CurrentPossibleRSize;x++){ if(PossibleR.at(x).first==a){ OtherPossibleR.push_back(make_pair(a,PossibleR.at(x).second+b)); } if(PossibleR.at(x).second==a){ OtherPossibleR.push_back(make_pair(PossibleR.at(x).first+b,a)); } if(PossibleR.at(x).first==b){ OtherPossibleR.push_back(make_pair(b,PossibleR.at(x).second+a)); } if(PossibleR.at(x).second==b){ OtherPossibleR.push_back(make_pair(PossibleR.at(x).first+a,b)); } } PossibleR = OtherPossibleR; } list<int> Output; for(int i =0;i<static_cast<int>(PossibleR.size());i++){ int OutputToPush = min(PossibleR.at(i).first,PossibleR.at(i).second); if(find(Output.begin(),Output.end(),OutputToPush)!=Output.end()){continue;}; Output.push_front(OutputToPush); } cout << Output.size() << endl; Output.sort(); int LastNum = 0; for(int i : Output){ if(LastNum==i){continue;}; LastNum = i; cout << i << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...