Submission #784432

# Submission time Handle Problem Language Result Execution time Memory
784432 2023-07-16T06:21:22 Z canadavid1 Archery (IOI09_archery) C++14
21 / 100
2000 ms 5036 KB
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x),end(x)
#define both(x) x.first,x.second
signed main()
{
    int N,R,rank;
    cin >> N >> R >> rank;
    vector<int> ranks(2*N-1);
    for(auto &&i : ranks) cin >> i;
    // will eventually have the top half (excluding the best) cycle around, and the worst half (excluding middle)
    // be stationary
    // lower numbers move
    // if rank == 1: any works, return  N
    if(rank == 1) {cout << N << "\n"; exit(0);}



    // just simulate all the positions
    int minend = INT_MAX;
    int position = -1;
    for(int pos = 2*N-2; pos >= 0; pos-=2)
    {
        vector<pair<int,int>> people;
        for(int i = 0; i < 2*N-1;)
        {
            if(i==pos) people.push_back({ranks[i++],rank});
            else people.push_back({ranks[i++],ranks[i++]});
        }
        for(int i = 0; i < R; i++)
        {
            if(i > 3*N && i < R-N)
            {
                i += ((R-i)/N)*N;
            }
            vector<pair<int,int>> people2(people.size());
            people2.back() = {max(both(people[0])),max(both(people.back()))};
            people2[0] = {min(both(people[0])),min(both(people[1]))};
            for(int i = 1; i < people.size()-1; i++)
            {
                people2[i] = {max(both(people[i])),min(both(people[i+1]))};
            }
            people = people2;
        }
        int r = 0; 
        for(; people[r].first!=rank && people[r].second != rank;r++);
        if(r < minend)
        {
            minend = r;
            position = pos/2+1;
        }
    }
    cout << position << "\n";


    // no.2 always moves to pos1, until 1 arrives, then cycles
        // unless it starts with 1, then it waits once first
    // no.3 always moves to pos1, until 2 or 1 arrives, then cycles
        // waits with starting until neither 1 nor 2 is at its position
        // can be complicated if (2 1) (3 ...)
        // as 1 moves up, and 3 comes to 2: (2 3) (...)
        // next, 2 moves up
}

Compilation message

archery.cpp: In function 'int main()':
archery.cpp:28:54: warning: operation on 'i' may be undefined [-Wsequence-point]
   28 |             else people.push_back({ranks[i++],ranks[i++]});
      |                                                     ~^~
archery.cpp:39:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int i = 1; i < people.size()-1; i++)
      |                            ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 10 ms 300 KB Output is correct
4 Execution timed out 2074 ms 340 KB Time limit exceeded
5 Correct 0 ms 212 KB Output is correct
6 Correct 59 ms 280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 73 ms 284 KB Output is correct
3 Execution timed out 2099 ms 212 KB Time limit exceeded
4 Execution timed out 2081 ms 672 KB Time limit exceeded
5 Execution timed out 2067 ms 4292 KB Time limit exceeded
6 Correct 61 ms 284 KB Output is correct
7 Execution timed out 2062 ms 212 KB Time limit exceeded
8 Execution timed out 2069 ms 596 KB Time limit exceeded
9 Execution timed out 2068 ms 852 KB Time limit exceeded
10 Execution timed out 2073 ms 212 KB Time limit exceeded
11 Execution timed out 2076 ms 852 KB Time limit exceeded
12 Execution timed out 2070 ms 356 KB Time limit exceeded
13 Execution timed out 2066 ms 3288 KB Time limit exceeded
14 Execution timed out 2069 ms 424 KB Time limit exceeded
15 Execution timed out 2061 ms 1104 KB Time limit exceeded
16 Correct 73 ms 212 KB Output is correct
17 Execution timed out 2081 ms 212 KB Time limit exceeded
18 Execution timed out 2080 ms 340 KB Time limit exceeded
19 Execution timed out 2076 ms 364 KB Time limit exceeded
20 Execution timed out 2074 ms 424 KB Time limit exceeded
21 Execution timed out 2084 ms 852 KB Time limit exceeded
22 Execution timed out 2087 ms 1104 KB Time limit exceeded
23 Execution timed out 2069 ms 4540 KB Time limit exceeded
24 Correct 50 ms 212 KB Output is correct
25 Execution timed out 2091 ms 212 KB Time limit exceeded
26 Execution timed out 2088 ms 340 KB Time limit exceeded
27 Execution timed out 2084 ms 852 KB Time limit exceeded
28 Execution timed out 2081 ms 3320 KB Time limit exceeded
29 Execution timed out 2082 ms 212 KB Time limit exceeded
30 Execution timed out 2087 ms 428 KB Time limit exceeded
31 Execution timed out 2087 ms 912 KB Time limit exceeded
32 Execution timed out 2064 ms 4456 KB Time limit exceeded
33 Correct 70 ms 212 KB Output is correct
34 Correct 63 ms 212 KB Output is correct
35 Execution timed out 2077 ms 340 KB Time limit exceeded
36 Execution timed out 2039 ms 340 KB Time limit exceeded
37 Execution timed out 2041 ms 724 KB Time limit exceeded
38 Execution timed out 2066 ms 976 KB Time limit exceeded
39 Correct 60 ms 288 KB Output is correct
40 Execution timed out 2073 ms 212 KB Time limit exceeded
41 Execution timed out 2076 ms 340 KB Time limit exceeded
42 Execution timed out 2083 ms 340 KB Time limit exceeded
43 Execution timed out 2059 ms 428 KB Time limit exceeded
44 Execution timed out 2075 ms 564 KB Time limit exceeded
45 Execution timed out 2070 ms 848 KB Time limit exceeded
46 Execution timed out 2087 ms 868 KB Time limit exceeded
47 Execution timed out 2086 ms 5036 KB Time limit exceeded