Submission #242331

#TimeUsernameProblemLanguageResultExecution timeMemory
242331cheehengJousting tournament (IOI12_tournament)C++14
Compilation error
0 ms0 KiB
#include <stdio.h> #include <stdlib.h> #include <assert.h> #define inbuf_len 1 << 16 #define outbuf_len 1 << 16 #include <bits/stdc++.h> using namespace std; int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { //printf("here"); vector<int> X; X.push_back(1); for(int i = 0; i < N-1; i ++){ if(K[i] < R){ X.push_back(0); }else{ X.push_back(2); } } int ans = 0; int bestIndx = -1; for(int i = 0; i < N; i ++){ vector<int> Y; for(int j: X){ Y.push_back(j); } /*for(int j: Y){ printf("%d", j); } printf("\n"); printf("i=%d\n", i);*/ int temp = 0; for(int j = 0; j < C; j ++){ int max1 = 0; for(int k = S[j]; k <= E[j]; k ++){ max1 = max(max1, Y[k]); } for(int k = S[j]; k <= E[j]; k ++){ Y.erase(Y.begin()+S[j]); } temp += (max1 == 1); Y.insert(Y.begin()+S[j], max1); /*for(int j: Y){ printf("%d", j); } printf("\n");*/ } //printf("temp=%d\n", temp); if(temp > ans){ ans = temp; bestIndx = i; } if(i+1 < N){ swap(X[i], X[i+1]); } } return bestIndx; } int main() { int tmp; /* Set input and output buffering */ char *inbuf, *outbuf; inbuf = (char*) malloc(inbuf_len * sizeof(char)); outbuf = (char*) malloc(outbuf_len * sizeof(char)); tmp = setvbuf(stdin, inbuf, _IOFBF, inbuf_len); assert(tmp == 0); tmp = setvbuf(stdout, outbuf, _IOFBF, outbuf_len); assert(tmp == 0); int N, C, R; int *K, *S, *E; tmp = scanf("%d %d %d", &N, &C, &R); assert(tmp == 3); K = (int*) malloc((N-1) * sizeof(int)); S = (int*) malloc(C * sizeof(int)); E = (int*) malloc(C * sizeof(int)); int i; for (i = 0; i < N-1; i++) { tmp = scanf("%d", &K[i]); assert(tmp == 1); } for (i = 0; i < C; i++) { tmp = scanf("%d %d", &S[i], &E[i]); assert(tmp == 2); } printf("%d\n", GetBestPosition(N, C, R, K, S, E)); return 0; }

Compilation message (stderr)

/tmp/ccRA1E37.o: In function `main':
tournament.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccfuZN1o.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status