Submission #206041

#TimeUsernameProblemLanguageResultExecution timeMemory
206041SegtreeSorting (IOI15_sorting)C++14
20 / 100
9 ms376 KiB
#include"sorting.h" #include<iostream> #include<algorithm> #include<vector> #include<queue> using namespace std; typedef long long ll; #define chmin(a,b) a=min(a,b) #define chmax(a,b) a=max(a,b) #define all(x) x,begin(),x.end() #define rep(i,n) for(int i=0;i<n;i++) #define mod 1000000007 #define mad(a,b) a=(a+b)%mod int findSwapPairs(int N,int S[],int M,int X[],int Y[],int P[],int Q[]){ int hoz[2010]; rep(i,N)hoz[i]=S[i]; int R=0; for(int i=0;i<N;i++){ ll p; for(int j=0;j<N;j++)if(S[j]==i)p=j; if(i!=p){ P[R]=S[i],Q[R]=S[p]; //cout<<"QP:"<<P[R]<<" "<<Q[R]<<endl; R++; swap(S[i],S[p]); } } rep(i,N)S[i]=hoz[i]; for(int i=0;i<R;i++){ ll valp=P[i],valq=Q[i]; ll place_p,place_q; for(int j=0;j<N;j++){ if(S[j]==valp)place_p=j; if(S[j]==valq)place_q=j; } swap(S[place_p],S[place_q]); P[i]=place_p,Q[i]=place_q; } //rep(i,R)cout<<"PQ:"<<P[i]<<" "<<Q[i]<<endl; return R; } /* int main(){ int n,s[100],m,x[1000],y[1000],p[1000],q[1000]; cin>>n; rep(i,n)cin>>s[i]; cin>>m; rep(i,m){ cin>>x[i]>>y[i]; } cout<<"R="<<findSwapPairs(n,s,m,x,y,p,q)<<endl; }*/

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:37:8: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
   P[i]=place_p,Q[i]=place_q;
        ^~~~~~~
sorting.cpp:37:21: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
   P[i]=place_p,Q[i]=place_q;
                     ^~~~~~~
sorting.cpp:14:37: warning: unused parameter 'M' [-Wunused-parameter]
 int findSwapPairs(int N,int S[],int M,int X[],int Y[],int P[],int Q[]){
                                     ^
sorting.cpp:14:45: warning: unused parameter 'X' [-Wunused-parameter]
 int findSwapPairs(int N,int S[],int M,int X[],int Y[],int P[],int Q[]){
                                             ^
sorting.cpp:14:53: warning: unused parameter 'Y' [-Wunused-parameter]
 int findSwapPairs(int N,int S[],int M,int X[],int Y[],int P[],int Q[]){
                                                     ^
sorting.cpp:37:15: warning: 'place_q' may be used uninitialized in this function [-Wmaybe-uninitialized]
   P[i]=place_p,Q[i]=place_q;
   ~~~~~~~~~~~~^~~~~~~~~~~~~
sorting.cpp:37:15: warning: 'place_p' may be used uninitialized in this function [-Wmaybe-uninitialized]
sorting.cpp:21:3: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if(i!=p){
   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...