Submission #795543

# Submission time Handle Problem Language Result Execution time Memory
795543 2023-07-27T11:07:39 Z Cauchico Sorting (IOI15_sorting) C++14
36 / 100
9 ms 596 KB
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
 
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    int n = N, m = M;
	for (int i=n;i<m;i++) {
		P[i] = Q[i] = 0;
	}
	vector<int> p,q;
	bool toswap = true;
	for (int i=2;i<n;i++) {
		if (Y[0] == 1 and toswap) {
			swap(S[0],S[1]);
			toswap = false;
		}
		for (int j=0;j<n;j++) {
			if (S[j] == i and i != j) {
				swap(S[j], S[i]);
				p.push_back(i);
				q.push_back(j);
				toswap = true;
			}
		}
	}
	if (S[0] != 0) {
		p.push_back(0);
		if (Y[0] == 1 and toswap) q.push_back(0);
		else q.push_back(1);
	} else if (Y[0] == 1 and toswap == false) {
		p.push_back(0);
		q.push_back(0);
	}
	for (int i=0;i<p.size();i++) {
		P[i] = p[i];
		Q[i] = q[i];
	}	
	return p.size();
 
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:34:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for (int i=0;i<p.size();i++) {
      |               ~^~~~~~~~~
sorting.cpp:38:15: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   38 |  return p.size();
      |         ~~~~~~^~
sorting.cpp:5:46: warning: unused parameter 'X' [-Wunused-parameter]
    5 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 292 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 292 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Incorrect 2 ms 596 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 400 KB Output isn't correct
2 Halted 0 ms 0 KB -