제출 #140554

#제출 시각아이디문제언어결과실행 시간메모리
140554SirCeness정렬하기 (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){ int flag = 1; for (int j = i+1; j < n; j++){ if (sanal[j] == i){ deg.pb(mp(sanal[i], sanal[j])); swap(sanal[i], sanal[j]); flag = 0; break; } } if (flag) assert(0); } } //for (int i = 0; i < deg.size(); i++) cout << ppair(deg[i]) << " "; cout << endl; int r = deg.size(); assert(r <= m); 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 n == 1 ? 0 : m; }

컴파일 시 표준 에러 (stderr) 메시지

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:48: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...