Submission #134282

# Submission time Handle Problem Language Result Execution time Memory
134282 2019-07-22T10:37:46 Z Runtime_error_ Sorting (IOI15_sorting) C++14
0 / 100
4 ms 376 KB
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    if(N < 2)
        return 0;
    int l =2, r =0,tr=0;
    while(S[l] == l && l<N)
            l++;
    for(int i=0;i<N;i++)
        if(S[i] != i)
            tr++;
    if(tr = 0)
        return 0;
    for(int i=0;i<M;i++){
        swap( S[ X[i] ],S[ Y[i] ] );
//        if(S[0] == 0 && S[1] == 1 && l == N)
//            return i;
        while(S[l] == l && l<N)
            l++;
        if( l == N){

//        for(int i=0;i<N;i++)
//            cout<<S[i]<<" ";
            if(S[0] == 0 && S[1] == 1){
                P[i] = 0,Q[i] = 0;
                i++;
                return i;
                }
            P[i]=0,Q[i] = 1;
            i++;
            return i;
        }
        int j;
        for(j=0;j<N;j++)
            if(S[j] == l)
                break;
        P[i] = l , Q[i] = j;
        swap(S[l],S[j]);
    }

}


Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:14:11: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     if(tr = 0)
        ~~~^~~
sorting.cpp:8:15: warning: unused variable 'r' [-Wunused-variable]
     int l =2, r =0,tr=0;
               ^
sorting.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -