Submission #426833

#TimeUsernameProblemLanguageResultExecution timeMemory
426833ollelSorting (IOI15_sorting)C++17
0 / 100
2 ms332 KiB
#include <bits/stdc++.h> #include <iostream> using namespace std; #define rep(i,a,b) for(int i = a; i < b; i++) #define pb push_back #define lso(x) x&(-x) typedef long long ll; typedef vector<ll> vi; typedef vector<vi> vvi; int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) { vi to(n), from(n); rep(i,0,n) to[i] = S[i]; rep(i,0,n) from[S[i]] = i; vector<bool> s(n, false); int r = 0; rep(i,0,n) { if (s[i]) continue; int x = i; while (!s[x]) { P[r] = x; Q[r] = to[x]; x = to[x]; s[x] = true; r++; } } return r; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:27:18: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   27 |       Q[r] = to[x];
      |                  ^
sorting.cpp:28:15: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   28 |       x = to[x];
      |               ^
sorting.cpp:13:39: warning: unused parameter 'M' [-Wunused-parameter]
   13 | int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
sorting.cpp:13:46: warning: unused parameter 'X' [-Wunused-parameter]
   13 | int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
sorting.cpp:13:55: warning: unused parameter 'Y' [-Wunused-parameter]
   13 | int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                                   ~~~~^~~
#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...