Submission #150407

# Submission time Handle Problem Language Result Execution time Memory
150407 2019-09-01T08:21:00 Z 1 WA = 5 Push Up(#3624, BaaaaaaaaaaaaaaaarkingDog, IohcEjnim, 0xrgb) Lokahian Relics (FXCUP4_lokahia) C++17
0 / 100
7 ms 688 KB
#include "lokahia.h"
#include <stdlib.h>
#include <algorithm>
#include <stdio.h>
using namespace std;
int p[706];
int query[706][3];

int find(int a){
  if(p[a] < 0) return a;
  return p[a] = find(p[a]);
}
int uni(int a, int b){
  a = find(a);
  b = find(b);
  if(a==b) return 0;
  p[a] += p[b];
  p[b] = a;
  return -p[a];
}

int FindBase(int N){
  srand(234316);
  int GROUP_IDX = N+1;
  if(N==1) return 0;
  for(int i = 0; i < 700; i++){
    p[i] = -1;
  }
  int GUESS_IDX = 0;
  while(GUESS_IDX < 400){
    int a = 0, b = 0;
    while(find(a) == find(b)){
      a = rand()%N;
      b = rand()%N;
      //printf("%d %d %d %d\n",a,b,find(a),find(b));
    }
    int ret = CollectRelics(a,b);
    //printf("%d %d %d\n",a,b,ret);
    query[GUESS_IDX][0]=a;
    query[GUESS_IDX][1]=b;
    query[GUESS_IDX][2]=ret;
    if(ret != -1){
      int sz = uni(a, b);
      if(sz > N/2){
        int ret = -1;
        for(int i = 0; i < GUESS_IDX; i++){
          if(find(query[GUESS_IDX][0]) != find(a) or find(query[GUESS_IDX][1]) != find(a)) continue;
          ret = max(ret, query[GUESS_IDX][1]);         
        }
        return ret;
      }
    }
    GUESS_IDX++;
  }
  int mxidx = 0;
  for(int i = 0; i < N; i++){
    if(-p[i] > -p[mxidx]) mxidx = i;
  }
	int ret = -1;
  for(int i = 0; i < GUESS_IDX; i++){
    if(find(query[GUESS_IDX][0]) != find(mxidx) or find(query[GUESS_IDX][1]) != find(mxidx)) continue;
    ret = max(ret, query[GUESS_IDX][1]);
  }
  int cnt = 1;
  for(int i = 0; i < N; i++){
    if(i==ret) continue;
    if(CollectRelics(i,ret) != -1) cnt++;
  }
  if(cnt > N/2) return ret;
  else return -1;
}

Compilation message

lokahia.cpp: In function 'int FindBase(int)':
lokahia.cpp:24:7: warning: unused variable 'GROUP_IDX' [-Wunused-variable]
   int GROUP_IDX = N+1;
       ^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 640 KB Wrong
2 Incorrect 6 ms 640 KB Wrong
3 Incorrect 7 ms 640 KB Wrong
4 Incorrect 6 ms 640 KB Wrong
5 Incorrect 7 ms 640 KB Wrong
6 Correct 6 ms 512 KB Correct : C = 233
7 Incorrect 6 ms 512 KB Wrong
8 Partially correct 6 ms 512 KB Partially correct : C = 518
9 Incorrect 6 ms 512 KB Wrong
10 Partially correct 6 ms 512 KB Partially correct : C = 598
11 Incorrect 7 ms 640 KB Wrong
12 Incorrect 6 ms 512 KB Wrong
13 Incorrect 6 ms 512 KB Wrong
14 Partially correct 6 ms 512 KB Partially correct : C = 599
15 Partially correct 5 ms 384 KB Partially correct : C = 519
16 Incorrect 7 ms 640 KB Wrong
17 Incorrect 6 ms 640 KB Wrong
18 Incorrect 6 ms 512 KB Wrong
19 Incorrect 7 ms 640 KB Wrong
20 Incorrect 6 ms 512 KB Wrong
21 Incorrect 6 ms 512 KB Wrong
22 Correct 6 ms 512 KB Correct : C = 0
23 Incorrect 6 ms 688 KB Wrong
24 Incorrect 6 ms 512 KB Wrong
25 Incorrect 7 ms 640 KB Wrong
26 Incorrect 6 ms 512 KB Wrong
27 Incorrect 7 ms 640 KB Wrong