답안 #465459

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
465459 2021-08-16T07:31:29 Z daisy Xor Sort (eJOI20_xorsort) C++17
0 / 100
1 ms 204 KB
#include<iostream>
#include<algorithm>
#include<vector>
#define endl '\n'
using namespace std;
int n,s,p[1005];
pair<int,int> m[1005];
bool cmp(pair<int,int> a, pair<int,int> b)
{
    return a.first>b.first;
}
vector< pair<int,int> > v;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>s;

    for(int i=1;i<=n;i++){
        cin>>m[i].first;
        m[i].second=i;
     }
     sort(m+1,m+n+1,cmp);
     int t;

    for(int i=1;i<=n;i++)
    {
        t=m[i].second-p[m[i].second];
        for(int j=m[i].second+1;j<=n;j++) p[j]++;

        for(int j=1;j<=n-i+1;j++)
        {
            v.push_back({j,j+1});
            //cout<<j<<" "<<j+1<<endl;
        }
        for(int j=t+1;j<=n-i+1;j++)
        {
            v.push_back({j,j-1});
            //cout<<j<<" "<<j-1<<endl;
        }
        for(int j=t-2;j>=1;j--)
        {
            v.push_back({j,j+1});
            //cout<<j<<" "<<j+1<<endl;
        }
    }
  cout<<v.size()<<endl;

   for(int i=0;i<v.size();i++)
   {
       cout<<v[i].first<<" "<<v[i].second<<endl;
   }

}

Compilation message

xorsort.cpp: In function 'int main()':
xorsort.cpp:51:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |    for(int i=0;i<v.size();i++)
      |                ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -