Submission #790143

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7901432023-07-22 11:05:58PoonYaPatSorting (IOI15_sorting)C++14
54 / 100
46 ms500 KiB
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int n,m,b[200005],x[200005],y[200005],p[200005];
vector<pii> ans;
int a[200005],pos[200005],val[200005],c[200005];
bool check(int h, bool mode) {
for (int i=0; i<n; ++i) a[i]=i, val[i]=i, c[i]=b[i], p[i]=i;
for (int i=h; i>=0; --i) swap(a[x[i]],a[y[i]]);
vector<pii> v;
for (int i=0; i<n; ++i) pos[c[i]]=i;
for (int i=0; i<n; ++i) {
if (c[i]!=a[i]) {
v.push_back(pii(i,pos[a[i]]));
swap(pos[a[i]],pos[c[i]]);
swap(c[pos[c[i]]],c[i]);
}
}
reverse(v.begin(),v.end());
if (mode) {
for (int i=0; i<=h; ++i) {
swap(val[p[x[i]]],val[p[y[i]]]);
swap(p[x[i]],p[y[i]]);
if (v.size()) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

sorting.cpp: In function 'bool check(int, bool)':
sorting.cpp:37:14: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |  if (v.size()<=h+1) return true;
      |      ~~~~~~~~^~~~~
sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:52:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for (int i=0; i<ans.size(); ++i) P[i]=ans[i].first, Q[i]=ans[i].second;
      |                ~^~~~~~~~~~~
sorting.cpp:53:17: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   53 |  return ans.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...