Submission #528226

# Submission time Handle Problem Language Result Execution time Memory
528226 2022-02-19T17:43:53 Z AndresTL Archery (IOI09_archery) C++11
9 / 100
2000 ms 65536 KB
#include<bits/stdc++.h>
using namespace std;
const int LIMIT=(200000*2)+5;
int level[LIMIT];
int Objetivos, Rounds;
vector<pair<int,int>> Campo;
int bucket[LIMIT];
int bucle(){
  int c1 = 0; bool myArcher=0;
  for(int i=0;i<2*Objetivos;i++){
    if(i == 0){
        if(Campo[i].first == 1) c1 ++;
        if(Campo[i].second == 1) c1++;
        if(Campo[i].first==level[1] || Campo[i].second==level[1]) myArcher=1;
    }else{
      if(Campo[i].first)c1++;
      if(Campo[i].second)c1++;
      if(Campo[i].first==level[1] || Campo[i].second==level[1]) myArcher=1;
    }
    if(c1 > 1){
      Campo.push_back(make_pair(1,0));
      c1--;
    } else if(c1 == 1){
      if(myArcher){
        Campo.push_back(make_pair(level[1],0));
        myArcher=0;
        if(i+1 >= Objetivos) return (Objetivos - ((Rounds - i+1) % Objetivos));
      }else{
        Campo.push_back(make_pair(0, 0));
      }
    }else{
      Campo.push_back(make_pair(0, 0));
    }
  }
}
int nobucle(){
  for(int i=0;i<=Objetivos;i++){
    bucket[i]=0;
  }
  int pos=0;
  for(int i=0;i<Objetivos;i++){
    if(Campo[i].first==0) bucket[i+1]++;
    if(Campo[i].second==0) bucket[i+1]++;
    if(Campo[i].first==level[1] || Campo[i].second==level[1])pos=i+1; 
  }
  int c0=bucket[1];
  bool myArcher=0;
  bucket[1]=0;
  if(pos==1) myArcher=1;
  for(int i=Objetivos;i>=2;i--){
    if(pos==i)myArcher=1;
    if(bucket[i]==0 && c0==0 && myArcher){
      pos=i;
      myArcher=0;
    }else if(bucket[i]==0 && c0!=0){
      c0--;
      bucket[i]++;
    }else if(bucket[i]>0){
      c0+=bucket[i]-1;
      bucket[i]=1;
    }
  }
  c0=bucket[1];
  myArcher=0;
   if(pos==1) myArcher=1;
  bucket[1]=0;
  for(int i=Objetivos;i>=2;i--){
    if(pos==i)myArcher=1;
    if(bucket[i]==0 && c0==0 && myArcher){
      pos=i;
      myArcher=0;
    }else if(bucket[i]==0 && c0!=0){
      c0--;
      bucket[i]++;
    }else if(bucket[i]>0){
      c0+=bucket[i]-1;
      bucket[i]=1;
    }
  }
  return pos;
}
int solve(int ini){
  Campo.clear();
  bool x,y;
  for(int i=2, j=1; i<=2*Objetivos;i+=2,j++){
    x=(level[i]<level[1])?1:0;
    y=(level[i+1]<level[1])?1:0;
    if(j==ini){ 
      Campo.push_back(make_pair(x,level[1]));
      i--;
    }else Campo.push_back(make_pair(x,y));
  }
  int z=0;
  if(level[1]<=Objetivos+1){
    z=bucle();
  }else{
    z=nobucle();
  }
  return z;
}
int main(){
  ios_base::sync_with_stdio(0);cin.tie();
  cin>>Objetivos>>Rounds;
  for(int i=1;i<=Objetivos*2;i++){
    cin>>level[i];
  }
  int res,mpos,pos;
  for(int i=1;i<=Objetivos;i++){
    pos=solve(i);
    if(mpos>=pos){
      mpos=pos;
      res=i;
    }
  }
  cout<<res;
}

Compilation message

archery.cpp: In function 'int bucle()':
archery.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^
archery.cpp: In function 'int main()':
archery.cpp:115:9: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
  115 |   cout<<res;
      |         ^~~
archery.cpp:110:5: warning: 'mpos' may be used uninitialized in this function [-Wmaybe-uninitialized]
  110 |     if(mpos>=pos){
      |     ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 31 ms 332 KB Output isn't correct
3 Runtime error 69 ms 65536 KB Execution killed with signal 9
4 Incorrect 89 ms 452 KB Output isn't correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Incorrect 30 ms 400 KB Output isn't correct
4 Execution timed out 2095 ms 1088 KB Time limit exceeded
5 Execution timed out 2047 ms 6468 KB Time limit exceeded
6 Incorrect 2 ms 332 KB Output isn't correct
7 Incorrect 12 ms 332 KB Output isn't correct
8 Execution timed out 2074 ms 1084 KB Time limit exceeded
9 Execution timed out 2067 ms 1104 KB Time limit exceeded
10 Correct 17 ms 332 KB Output is correct
11 Execution timed out 2079 ms 1112 KB Time limit exceeded
12 Incorrect 109 ms 460 KB Output isn't correct
13 Execution timed out 2041 ms 3500 KB Time limit exceeded
14 Incorrect 344 ms 596 KB Output isn't correct
15 Execution timed out 2088 ms 1740 KB Time limit exceeded
16 Incorrect 1 ms 332 KB Output isn't correct
17 Incorrect 23 ms 396 KB Output isn't correct
18 Incorrect 52 ms 448 KB Output isn't correct
19 Incorrect 161 ms 460 KB Output isn't correct
20 Correct 316 ms 588 KB Output is correct
21 Execution timed out 2062 ms 1104 KB Time limit exceeded
22 Execution timed out 2064 ms 1740 KB Time limit exceeded
23 Execution timed out 2025 ms 6612 KB Time limit exceeded
24 Incorrect 1 ms 204 KB Output isn't correct
25 Incorrect 17 ms 356 KB Output isn't correct
26 Incorrect 408 ms 472 KB Output isn't correct
27 Execution timed out 2065 ms 848 KB Time limit exceeded
28 Execution timed out 2058 ms 2868 KB Time limit exceeded
29 Incorrect 28 ms 332 KB Output isn't correct
30 Incorrect 318 ms 476 KB Output isn't correct
31 Execution timed out 2087 ms 848 KB Time limit exceeded
32 Execution timed out 2035 ms 4544 KB Time limit exceeded
33 Incorrect 1 ms 204 KB Output isn't correct
34 Correct 1 ms 204 KB Output is correct
35 Incorrect 57 ms 332 KB Output isn't correct
36 Incorrect 82 ms 332 KB Output isn't correct
37 Execution timed out 2063 ms 844 KB Time limit exceeded
38 Execution timed out 2081 ms 848 KB Time limit exceeded
39 Incorrect 1 ms 204 KB Output isn't correct
40 Incorrect 14 ms 352 KB Output isn't correct
41 Incorrect 57 ms 332 KB Output isn't correct
42 Incorrect 79 ms 332 KB Output isn't correct
43 Incorrect 325 ms 476 KB Output isn't correct
44 Incorrect 1270 ms 708 KB Output isn't correct
45 Execution timed out 2098 ms 848 KB Time limit exceeded
46 Execution timed out 2095 ms 848 KB Time limit exceeded
47 Execution timed out 2090 ms 4796 KB Time limit exceeded