Submission #1089783

# Submission time Handle Problem Language Result Execution time Memory
1089783 2024-09-17T06:48:54 Z SalihSahin Knjige (COCI20_knjige) C++14
50 / 50
34 ms 3548 KB
#include<bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;

const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2048;

vector<array<string, 3> > ans;

void operation(int type, int hand, int shelf){ // take = 0, left = 0
  array<string, 3> op;
  if(!type) op[0] = "UZMI";
  else op[0] = "STAVI";

  if(!hand) op[1] = "L";
  else op[1] = "D";

  if(!shelf) op[2] = "L";
  else op[2] = "D";

  ans.pb(op);
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> ls, rs;
  for(int i = 0; i < n; i++){
    int x;
    cin>>x;
    ls.pb(x);
    a[i] = x;
  }
  reverse(ls.begin(), ls.end());
  sort(a.rbegin(), a.rend());

  for(int i = 0; i < n-1; i++){
    if(ls[i] == a[i]) continue;
    bool vis = 0;

    while(ls.size() > i){
      if(ls.back() == a[i] && !vis){
        operation(0, 1, 0);
        vis = true;
      }
      else{
        operation(0, 0, 0);
        rs.pb(ls.back());
        operation(1, 0, 1);
      }
      ls.pop_back();
    }
    if(vis){
      operation(1, 1, 0);
      ls.pb(a[i]);
    }
    while(!rs.empty()){
      operation(0, 0, 1);
      ls.pb(rs.back());
      rs.pop_back();
      operation(1, 0, 0);
    }
  }

  cout<<ans.size()<<endl;
  for(auto itr: ans){
    cout<<itr[0]<<" "<<itr[1]<<" "<<itr[2]<<endl;
  }
  return 0;
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:46:21: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   46 |     while(ls.size() > i){
      |           ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 22 ms 3536 KB Output is correct
2 Correct 25 ms 3536 KB Output is correct
3 Correct 22 ms 3532 KB Output is correct
4 Correct 25 ms 3536 KB Output is correct
5 Correct 34 ms 3548 KB Output is correct
6 Correct 23 ms 3536 KB Output is correct
7 Correct 17 ms 2012 KB Output is correct
8 Correct 22 ms 3540 KB Output is correct
9 Correct 23 ms 3548 KB Output is correct
10 Correct 23 ms 3540 KB Output is correct