Submission #302041

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3020412020-09-18 11:37:03BertedSorting (IOI15_sorting)C++14
100 / 100
298 ms36484 KiB
#include "sorting.h"
#include <vector>
#include <iostream>
#define pii pair<int, int>
#define fst first
#define snd second
using namespace std;
int N, A[200001], T[200001], pos[200001];
pii S[600001];
bool vis[200001];
vector<int> check;
void DFS(int u)
{
if (!vis[u])
{
vis[u] = 1;
check.push_back(u);
DFS(T[u]);
}
}
vector<pii> getSwaps(int x)
{
vector<pii> ret;
for (int i = 0; i < N; i++) {T[i] = A[i]; vis[i] = 0;}
for (int i = 0; i < x; i++) {swap(T[S[i].fst], T[S[i].snd]);}
for (int i = 0; i < N; i++)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

sorting.cpp: In function 'std::vector<std::pair<int, int> > getSwaps(int)':
sorting.cpp:33:12: warning: declaration of 'i' shadows a previous local [-Wshadow]
   33 |   for (int i = 1; i < check.size(); i++) {ret.push_back({check[i - 1], check[i]});}
      |            ^
sorting.cpp:30:11: note: shadowed declaration is here
   30 |  for (int i = 0; i < N; i++)
      |           ^
sorting.cpp:33:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for (int i = 1; i < check.size(); i++) {ret.push_back({check[i - 1], check[i]});}
      |                   ~~^~~~~~~~~~~~~~
sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:39:76: warning: declaration of 'S' shadows a global declaration [-Wshadow]
   39 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                                                            ^
sorting.cpp:11:5: note: shadowed declaration is here
   11 | pii S[600001];
      |     ^
sorting.cpp:39:76: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   39 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                                                            ^
sorting.cpp:10:5: note: shadowed declaration is here
   10 | int N, A[200001], T[200001], pos[200001];
      |     ^
sorting.cpp:48:7: warning: declaration of 'int M' shadows a parameter [-Wshadow]
   48 |   int M = L + R >> 1;
      |       ^
sorting.cpp:39:39: note: shadowed declaration is here
   39 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                   ~~~~^
sorting.cpp:48:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |   int M = L + R >> 1;
      |           ~~^~~
sorting.cpp:49:26: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |   if (getSwaps(M).size() <= M) {R = M;}
      |       ~~~~~~~~~~~~~~~~~~~^~~~
sorting.cpp:60:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |   if (i < V.size())
      |       ~~^~~~~~~~~~
#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...