I have a doubt in the first div 3 contest held in CF

Revision en1, by akanksha_11, 2021-05-18 07:26:54

`I am a beginner in CP and so I was solving the contest#977,which is the first div 3 contest. But I got stuck in D ques Can someone please tell me what's wrong in my approach?...My code is:

include

include

include

define ll __int64 using namespace std;

int main() { short n; cin >> n; ll a[n]; set nos, fixed; vector v; for (short i = 0; i < n; i++) { cin >> a[i]; fixed.insert(a[i]); } nos = fixed; short j = 0; ll s = a[j]; v.push_back(s); nos.erase(s); for (short i = 0; i < n; i++) { if (a[i] == s) continue; if ((s % 3 == 0) && (nos.count(s / 3))) { s /= 3; v.push_back(s); nos.erase(s); } if (nos.count(s * 2)) { s = s * 2; v.push_back(s); nos.erase(s); } if ((i + 1 == n) && (v.size() != n)) { v.clear(); i = -1; j++; s = a[j]; v.push_back(s); nos = fixed; nos.erase(s); } } for (short i = 0; i < n; i++) { cout << v[i] << endl; } return 0; } `

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English akanksha_11 2021-05-18 09:08:38 1491
en3 English akanksha_11 2021-05-18 09:01:44 50 Tiny change: 'n~~~~~\n\n `' -> 'n~~~~~\n\nUPD: Instead of downvoting...please help me out!\n `'
en2 English akanksha_11 2021-05-18 07:27:41 20
en1 English akanksha_11 2021-05-18 07:26:54 1402 Initial revision (published)