Submission #374014

#TimeUsernameProblemLanguageResultExecution timeMemory
374014gustasonASM (LMIO18_asm)C++11
0 / 100
1 ms384 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; #define int ll int n; vector<pair<int, int>> b; //void go(pair<int, int> a, bool print) { // if (print) { // // } //} bool check(vector<pair<char, int>> ins) { for(int i = 0; i < n; i++) { int x = b[i].first; for(auto j : ins) { if (j.first == 'm') { if (j.second < 0) return false; x *= j.second; } else if (j.first == 'a') { if (j.second < 0) return false; x += j.second; } if (x > b[i].second) return false; } if (x != b[i].second) return false; } return true; } void printAns(vector<pair<char, int>> ans) { cout << ans.size() << "\n"; for(auto i : ans) { if (i.first == 'm') { cout << "multiply " << i.second; } else if (i.first == 'a') { cout << "add " << i.second; } else { cout << "print"; } cout << "\n"; } exit(0); } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; b.resize(n); for(int i = 0; i < n; i++) { cin >> b[i].first >> b[i].second; } sort(b.begin(), b.end(), [](pair<int, int>& left, pair<int, int>& right){return left.second < right.second;}); int best = 100; vector<pair<char, int>> ans; vector<pair<char, int>> curr; curr.push_back({'a', b[0].second - b[0].first}); if (check(curr)) { if (curr[0].second == 0) curr.pop_back(); curr.push_back({'p', 0}); printAns(curr); } // one step for(int j = 2; j <= 100; j++) { vector<pair<char, int>>().swap(curr); curr.push_back({'m', j}); int add = b[0].second - (b[0].first * j); if (add > 0) { curr.push_back({'a', j}); } if (check(curr)) { printAns(curr); } } // split // for(int j = ) cout << -1; return 0; }

Compilation message (stderr)

asm.cpp: In function 'int main()':
asm.cpp:53:9: warning: unused variable 'best' [-Wunused-variable]
   53 |     int best = 100;
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...