Submission #465774

# Submission time Handle Problem Language Result Execution time Memory
465774 2021-08-16T18:38:55 Z daisy Xor Sort (eJOI20_xorsort) C++17
0 / 100
0 ms 204 KB
#include<iostream>
#include<vector>
#define endl '\n'
using namespace std;
pair<int,int> m[1005];
vector< pair<int,int> > v;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,s,b=0;
    cin>>n>>s;

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

    for(int i=(1<<20);i>=1;i/=2)
    {
        for(int j=1;j<n;j++)
        {
            if((i&m[j].first))
            {
                if(!(i&m[j+1].first))
                {
                    v.push_back({j+1,j});
                    //m[j+1].first^=m[j].first;
                }

                    v.push_back({j,j+1});
                   // m[j].first^=m[j+1].first;

            }
        }
    }
  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:41: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]
   41 |    for(int i=0;i<v.size();i++)
      |                ~^~~~~~~~~
xorsort.cpp:13:13: warning: unused variable 'b' [-Wunused-variable]
   13 |     int n,s,b=0;
      |             ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Not sorted
2 Halted 0 ms 0 KB -