Submission #252212

#TimeUsernameProblemLanguageResultExecution timeMemory
252212HeheheSorting (IOI15_sorting)C++14
20 / 100
1 ms512 KiB
#include<bits/stdc++.h> //:3 using namespace std; typedef long long ll; #define all(a) (a).begin(), (a).end() #define ff first #define ss second #define pb push_back #define mp make_pair #define rc(s) return cout<<s,0 #define pi pair <int, int> #define sz(x) (int)((x).size()) #include "sorting.h" const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; const ll H = 2e3 + 11; //ifstream in(".in"); //ofstream out(".out"); int pos[H]; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int n = N, m = M, cur = 0; for(int i = 0; i < n; i++){ pos[S[i]] = i; if(X[i] == 0 && Y[i] == 0)cur++; } vector<pi>ans; if(X[0] == 0 && Y[0] == 0){//subtask 1, 2 for(int i = 0; i < n; i++){ if(S[i] == i)continue; ans.push_back({i, pos[i]}); int x = i, y = S[i]; swap(S[i], S[pos[i]]); pos[y] = pos[i]; pos[x] = x; } int k = 0; for(auto it : ans){ P[k] = it.ff; Q[k] = it.ss; k++; } return sz(ans); }else{//subtask 3 /* swap(S[0], S[1]); //Ermek first move pos[S[0]] = 0; pos[S[1]] = 1;*/ for(int i = n - 1; i >= 1; i--){ if(S[i] == i)continue; ans.push_back({i, pos[i]}); int x = i, y = S[i]; swap(S[i], S[pos[i]]); pos[y] = pos[i]; pos[x] = x; if(i == 1)break; //his move swap(S[0], S[1]); pos[S[0]] = 0; pos[S[1]] = 1; } int k = 0; for(auto it : ans){ P[k] = it.ff; Q[k] = it.ss; k++; } return sz(ans); } }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:26:16: warning: unused variable 'm' [-Wunused-variable]
     int n = N, m = M, cur = 0;
                ^
#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...