답안 #528231

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528231 2022-02-19T17:55:46 Z AndresTL Archery (IOI09_archery) C++11
6 / 100
2000 ms 65540 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 = 1; 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];
  }
  if(level[1]==1){
    cout<<1<<'\n';
    return 0;
  }
  int res,mpos=INT_MAX,pos;
  for(int i=1;i<=Objetivos;i++){
    pos=solve(i);
    if(mpos>=pos){
      mpos=pos;
      res=i;
    }
  }
  cout<<res;
  return 0;
}

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:119:9: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
  119 |   cout<<res;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Runtime error 67 ms 65540 KB Execution killed with signal 9
4 Incorrect 93 ms 452 KB Output isn't correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Incorrect 33 ms 400 KB Output isn't correct
4 Execution timed out 2067 ms 1080 KB Time limit exceeded
5 Execution timed out 2086 ms 5864 KB Time limit exceeded
6 Incorrect 1 ms 332 KB Output isn't correct
7 Incorrect 13 ms 332 KB Output isn't correct
8 Execution timed out 2068 ms 1076 KB Time limit exceeded
9 Execution timed out 2074 ms 1108 KB Time limit exceeded
10 Incorrect 17 ms 400 KB Output isn't correct
11 Execution timed out 2085 ms 1104 KB Time limit exceeded
12 Incorrect 109 ms 460 KB Output isn't correct
13 Execution timed out 2083 ms 3368 KB Time limit exceeded
14 Incorrect 357 ms 568 KB Output isn't correct
15 Execution timed out 2099 ms 1740 KB Time limit exceeded
16 Incorrect 1 ms 332 KB Output isn't correct
17 Incorrect 25 ms 396 KB Output isn't correct
18 Incorrect 53 ms 440 KB Output isn't correct
19 Incorrect 176 ms 536 KB Output isn't correct
20 Correct 319 ms 576 KB Output is correct
21 Execution timed out 2087 ms 1104 KB Time limit exceeded
22 Execution timed out 2075 ms 1740 KB Time limit exceeded
23 Execution timed out 2094 ms 5948 KB Time limit exceeded
24 Incorrect 1 ms 204 KB Output isn't correct
25 Incorrect 17 ms 360 KB Output isn't correct
26 Incorrect 412 ms 460 KB Output isn't correct
27 Execution timed out 2093 ms 848 KB Time limit exceeded
28 Execution timed out 2100 ms 2880 KB Time limit exceeded
29 Incorrect 29 ms 332 KB Output isn't correct
30 Incorrect 310 ms 460 KB Output isn't correct
31 Execution timed out 2082 ms 848 KB Time limit exceeded
32 Execution timed out 2092 ms 3820 KB Time limit exceeded
33 Incorrect 1 ms 332 KB Output isn't correct
34 Correct 1 ms 332 KB Output is correct
35 Incorrect 59 ms 392 KB Output isn't correct
36 Incorrect 85 ms 332 KB Output isn't correct
37 Execution timed out 2080 ms 844 KB Time limit exceeded
38 Execution timed out 2090 ms 848 KB Time limit exceeded
39 Incorrect 1 ms 204 KB Output isn't correct
40 Incorrect 14 ms 360 KB Output isn't correct
41 Incorrect 61 ms 332 KB Output isn't correct
42 Incorrect 81 ms 332 KB Output isn't correct
43 Incorrect 326 ms 472 KB Output isn't correct
44 Incorrect 1303 ms 636 KB Output isn't correct
45 Execution timed out 2085 ms 848 KB Time limit exceeded
46 Execution timed out 2081 ms 868 KB Time limit exceeded
47 Execution timed out 2075 ms 4284 KB Time limit exceeded