Submission #223085

#TimeUsernameProblemLanguageResultExecution timeMemory
223085emil_physmathSorting (IOI15_sorting)C++17
Compilation error
0 ms0 KiB
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include "sorting.h"
using namespace std;

int s[1000000];
static char _buffer[1024];
static int _currentChar = 0;
static int _charsNumber = 0;
static FILE *_inputFile, *_outputFile;

static inline int _readInt() {
    int res;
    cin >> res;
    return res;
}

int main()
{
	int N, M;
	N = _readInt();
	int *S = (int*)malloc(sizeof(int) * (unsigned int)N);
	for (int i = 0; i < N; ++i)
		S[i] = _readInt();
	M = _readInt();
	int *X = (int*)malloc(sizeof(int) * (unsigned int)M), *Y = (int*)malloc(sizeof(int) * (unsigned int)M);
	for (int i = 0; i < M; ++i) {
	    X[i] = _readInt();
	    Y[i] = _readInt();
	}
	int *P = (int*)malloc(sizeof(int) * (unsigned int)M), *Q = (int*)malloc(sizeof(int) * (unsigned int)M);
    for (int i = 0; i < N; ++i)
        s[i] = S[i];
	int ans = findSwapPairs(N, s, M, X, Y, P, Q);
	printf("%d\n", ans);
	for (int i = 0; i < ans; ++i)
		printf("%d %d\n", P[i], Q[i]);
    for (int i = 0; i < ans; ++i)
    {
        swap(S[X[i]], S[Y[i]]);
        swap(S[P[i]], S[Q[i]]);
    }
    for (int i = 0; i < N; ++i)
        cout << S[i] << ' ';
}

Compilation message (stderr)

sorting.cpp: In function 'int main()':
sorting.cpp:34:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (int i = 0; i < N; ++i)
     ^~~
sorting.cpp:36:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  int ans = findSwapPairs(N, s, M, X, Y, P, Q);
  ^~~
sorting.cpp: At global scope:
sorting.cpp:12:27: warning: '_outputFile' defined but not used [-Wunused-variable]
 static FILE *_inputFile, *_outputFile;
                           ^~~~~~~~~~~
sorting.cpp:12:14: warning: '_inputFile' defined but not used [-Wunused-variable]
 static FILE *_inputFile, *_outputFile;
              ^~~~~~~~~~
sorting.cpp:11:12: warning: '_charsNumber' defined but not used [-Wunused-variable]
 static int _charsNumber = 0;
            ^~~~~~~~~~~~
sorting.cpp:10:12: warning: '_currentChar' defined but not used [-Wunused-variable]
 static int _currentChar = 0;
            ^~~~~~~~~~~~
sorting.cpp:9:13: warning: '_buffer' defined but not used [-Wunused-variable]
 static char _buffer[1024];
             ^~~~~~~
/tmp/ccPzjDKM.o: In function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'
/tmp/cct1xgLI.o:sorting.cpp:(.text.startup+0x0): first defined here
/tmp/cct1xgLI.o: In function `main':
sorting.cpp:(.text.startup+0x153): undefined reference to `findSwapPairs(int, int*, int, int*, int*, int*, int*)'
sorting.cpp:(.text.startup+0x2a1): undefined reference to `findSwapPairs(int, int*, int, int*, int*, int*, int*)'
/tmp/ccPzjDKM.o: In function `main':
grader.c:(.text.startup+0x517): undefined reference to `findSwapPairs(int, int*, int, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status