Submission #465460

# Submission time Handle Problem Language Result Execution time Memory
465460 2021-08-16T07:32:40 Z daisy Xor Sort (eJOI20_xorsort) C++17
60 / 100
198 ms 15780 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<=min(n-1,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++)
      |                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 264 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 5 ms 764 KB Output is correct
5 Correct 5 ms 720 KB Output is correct
6 Correct 5 ms 720 KB Output is correct
7 Correct 5 ms 720 KB Output is correct
8 Correct 5 ms 712 KB Output is correct
9 Correct 5 ms 732 KB Output is correct
10 Correct 5 ms 756 KB Output is correct
11 Correct 5 ms 720 KB Output is correct
12 Correct 5 ms 720 KB Output is correct
13 Correct 7 ms 720 KB Output is correct
14 Correct 5 ms 668 KB Output is correct
15 Correct 6 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 264 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 5 ms 764 KB Output is correct
5 Correct 5 ms 720 KB Output is correct
6 Correct 5 ms 720 KB Output is correct
7 Correct 5 ms 720 KB Output is correct
8 Correct 5 ms 712 KB Output is correct
9 Correct 5 ms 732 KB Output is correct
10 Correct 5 ms 756 KB Output is correct
11 Correct 5 ms 720 KB Output is correct
12 Correct 5 ms 720 KB Output is correct
13 Correct 7 ms 720 KB Output is correct
14 Correct 5 ms 668 KB Output is correct
15 Correct 6 ms 720 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 5 ms 720 KB Output is correct
18 Correct 8 ms 976 KB Output is correct
19 Correct 8 ms 976 KB Output is correct
20 Correct 9 ms 976 KB Output is correct
21 Correct 8 ms 976 KB Output is correct
22 Correct 11 ms 972 KB Output is correct
23 Correct 8 ms 976 KB Output is correct
24 Correct 8 ms 976 KB Output is correct
25 Correct 8 ms 976 KB Output is correct
26 Correct 8 ms 976 KB Output is correct
27 Correct 8 ms 1024 KB Output is correct
28 Correct 8 ms 976 KB Output is correct
29 Correct 9 ms 976 KB Output is correct
30 Correct 9 ms 976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 11 ms 1000 KB Output is correct
5 Incorrect 198 ms 15780 KB Integer 999006 violates the range [0, 40000]
6 Halted 0 ms 0 KB -