Submission #704897

# Submission time Handle Problem Language Result Execution time Memory
704897 2023-03-03T06:32:46 Z 1075508020060209tc Knjige (COCI20_knjige) C++14
0 / 50
4 ms 996 KB
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second

int n;
int ar[500005];
int freq[500005];
vector<pair<int,pair<char,char>>>ans;
stack<int>stkl;stack<int>stkr;
void swplr(){
ans.push_back({1,{'L','L'}});
ans.push_back({0,{'L','R'}});
stkr.push(stkl.top());
stkl.pop();
}
void swprl(){
ans.push_back({1,{'L','R'}});
ans.push_back({0,{'L','L'}});
stkl.push(stkr.top());
stkr.pop();
}

signed main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
cin>>n;
for(int i=n;i>=1;i--){
    cin>>ar[i];
}

for(int i=1;i<=n;i++){
    stkl.push(ar[i]);
    freq[ar[i]]++;
}

for(int i=1;i<=n;i++){
    swplr();
}
sort(ar+1,ar+n+1);
for(int i=n;i>=1;i--){
    int rhand=0;
    while(stkr.size()){
        if(stkr.top()==ar[i]&&rhand==0){
            ans.push_back({1,{'R','R'}});
            stkr.pop();
            continue;
        }
        swprl();
    }
    while(stkl.size()){
        swplr();
    }
        ans.push_back({0,{'R','L'}});
}
cout<<ans.size()<<endl;

for(int i=0;i<ans.size();i++){

    if(ans[i].first==0){
        cout<<"STAVI ";
    }else{
        cout<<"UZMI ";
    }
    if(ans[i].second.first=='R'){
        cout<<"D ";
    }else{
        cout<<"L ";
    }
    if(ans[i].second.second=='R'){
        cout<<"D\n";
    }else{
        cout<<"L\n";
    }

}


}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:60:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<char, char> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 | for(int i=0;i<ans.size();i++){
      |             ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 984 KB Cannot hold multiple books at one hand
2 Incorrect 3 ms 984 KB Cannot hold multiple books at one hand
3 Incorrect 4 ms 984 KB Cannot hold multiple books at one hand
4 Incorrect 3 ms 984 KB Cannot hold multiple books at one hand
5 Incorrect 3 ms 984 KB Cannot hold multiple books at one hand
6 Incorrect 2 ms 988 KB Cannot hold multiple books at one hand
7 Incorrect 2 ms 728 KB Cannot hold multiple books at one hand
8 Incorrect 2 ms 984 KB Cannot hold multiple books at one hand
9 Incorrect 3 ms 996 KB Cannot hold multiple books at one hand
10 Incorrect 2 ms 972 KB Cannot hold multiple books at one hand