Submission #140545

#TimeUsernameProblemLanguageResultExecution timeMemory
140545SirCenessSorting (IOI15_sorting)C++14
0 / 100
8 ms504 KiB
#include "sorting.h" #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define inside sl<=l&&r<=sr #define outside r<sl||sr<l #define orta ((l+r)>>1) #define INF 1000000009 #define mod 1000000007 #define ppair(x) "(" << x.first << ", " << x.second << ") " #define bas(x) #x << ": " << x << " " #define prarr(x, n); cerr << #x << ": "; for(int qsd = 0; qsd < n; qsd++) cerr << x[qsd] << " "; cerr << "\n"; #define prarrv(x); cerr << #x << ": "; for(int qsd = 0; qsd < (int)x.size(); qsd++) cerr << x[qsd] << " "; cerr << "\n"; using namespace std; typedef long long ll; int n, m; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { n = N; m = M; vector<int> sanal; for (int i = 0; i < n; i++) sanal.pb(S[i]); for (int i = 0; i < m; i++) swap(sanal[X[i]], sanal[Y[i]]); vector<int> sim; for (int i = 0; i < n; i++) sim.pb(S[i]); //prarrv(sanal); vector<pair<int, int> > deg; for (int i = 0; i < n; i++){ if (sanal[i] != i){ for (int j = i+1; j < n; j++){ if (sanal[j] == i){ deg.pb(mp(sanal[i], sanal[j])); swap(sanal[i], sanal[j]); break; } } } } //for (int i = 0; i < deg.size(); i++) cout << ppair(deg[i]) << " "; cout << endl; int r = deg.size(); for (int i = 0; i < M; i++){ swap(S[X[i]], S[Y[i]]); if (i >= r){ P[i] = 0; Q[i] = 0; continue; } for (int j = 0; j < n; j++){ if (S[j] == deg[i].first) P[i] = j; if (S[j] == deg[i].second) Q[i] = j; } swap(S[P[i]], S[Q[i]]); } /*prarrv(sim); for (int i = 0; i < m; i++){ swap(sim[X[i]], sim[Y[i]]); prarrv(sim); swap(sim[P[i]], sim[Q[i]]); prarrv(sim); }*/ return M; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:45:18: warning: conversion to 'int' from 'std::vector<std::pair<int, int> >::size_type {aka long unsigned int}' may alter its value [-Wconversion]
  int r = deg.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...