제출 #374018

#제출 시각아이디문제언어결과실행 시간메모리
374018gustasonASM (LMIO18_asm)C++11
0 / 100
1 ms492 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; int diff = b[0].second - b[0].first; curr.push_back({'a', diff}); if (diff < 0) { curr.pop_back(); curr.push_back({'m', 0}); b[0].first = 0; diff = b[0].second - b[0].first; if (diff != 0) curr.push_back({'a', diff}); } 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; }

컴파일 시 표준 에러 (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...