Submission #560300

# Submission time Handle Problem Language Result Execution time Memory
560300 2022-05-11T09:06:00 Z Koosha_mv Sorting (IOI15_sorting) C++14
8 / 100
1 ms 468 KB
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;
 
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
 
#define maxn 550
 
int n, m, a[maxn], pos[maxn], s1[maxn], s2[maxn];
 
int32_t findSwapPairs(int32_t N, int32_t a[], int32_t M, int32_t X[], int32_t Y[], int32_t P[], int32_t Q[]) {
    n = N;
    m = M;
    for(int i = 0; i < n; i++) {
        //a[i] = S[i];
        pos[a[i]] = i;
    }
 
    for(int i = 0; i < m; i++) {
        s1[i] = X[i];
        s2[i] = Y[i];
    }
 
    int32_t R = 0;
    for(int i = 0; i < n; i++) {
        if(pos[i] != i) {
            //swap a[i] and a[pos[i]]
            P[R] = i;
            Q[R] = pos[i];
            //pos[i] = i
            //pos[a[i]] = pos[i]
            swap(pos[i],pos[a[i]]);
            swap(a[P[R]],a[Q[R]]);
            R++;
        }
    }
 
    return R;
}

Compilation message

sorting.cpp: In function 'int32_t findSwapPairs(int32_t, int32_t*, int32_t, int32_t*, int32_t*, int32_t*, int32_t*)':
sorting.cpp:20:42: warning: declaration of 'a' shadows a global declaration [-Wshadow]
   20 | int32_t findSwapPairs(int32_t N, int32_t a[], int32_t M, int32_t X[], int32_t Y[], int32_t P[], int32_t Q[]) {
      |                                  ~~~~~~~~^~~
sorting.cpp:18:11: note: shadowed declaration is here
   18 | int n, m, a[maxn], pos[maxn], s1[maxn], s2[maxn];
      |           ^
sorting.cpp:37:20: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   37 |             P[R] = i;
      |                    ^
sorting.cpp:38:25: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   38 |             Q[R] = pos[i];
      |                    ~~~~~^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 244 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Runtime error 1 ms 468 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 244 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Runtime error 1 ms 468 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -