Submission #387262

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3872622021-04-08 07:47:08ParsaAlizadehSorting (IOI15_sorting)C++17
100 / 100
204 ms22600 KiB
#include <bits/stdc++.h>
#include "sorting.h"
using namespace std;
typedef pair<int, int> pii;
vector<int> perm;
vector<pii> alice, bob;
bool check(int t) {
vector<int> tmp(perm);
for (int i = 0; i < t; i++) {
swap(tmp[alice[i].first], tmp[alice[i].second]);
}
bob.clear();
for (int i = 0; i < tmp.size(); i++) {
while (tmp[i] != i) {
bob.emplace_back(tmp[i], tmp[tmp[i]]);
swap(tmp[i], tmp[tmp[i]]);
}
}
while (bob.size() < t)
bob.emplace_back(0, 0);
return bob.size() == t;
}
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
perm.assign(S, S + N);
for (int i = 0; i < M; i++) {
alice.emplace_back(X[i], Y[i]);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

sorting.cpp: In function 'bool check(int)':
sorting.cpp:16:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for (int i = 0; i < tmp.size(); i++) {
      |                  ~~^~~~~~~~~~~~
sorting.cpp:22:20: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |  while (bob.size() < t)
      |         ~~~~~~~~~~~^~~
sorting.cpp:24:20: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |  return bob.size() == t;
      |         ~~~~~~~~~~~^~~~
#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...