Submission #784433

# Submission time Handle Problem Language Result Execution time Memory
784433 2023-07-16T06:24:23 Z canadavid1 Archery (IOI09_archery) C++14
21 / 100
2000 ms 5208 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 > 2*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 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 7 ms 212 KB Output is correct
4 Execution timed out 2072 ms 340 KB Time limit exceeded
5 Correct 1 ms 212 KB Output is correct
6 Correct 42 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 68 ms 284 KB Output is correct
3 Execution timed out 2086 ms 212 KB Time limit exceeded
4 Execution timed out 2072 ms 596 KB Time limit exceeded
5 Execution timed out 2084 ms 4288 KB Time limit exceeded
6 Correct 42 ms 212 KB Output is correct
7 Execution timed out 2064 ms 212 KB Time limit exceeded
8 Execution timed out 2065 ms 596 KB Time limit exceeded
9 Execution timed out 2063 ms 856 KB Time limit exceeded
10 Execution timed out 2072 ms 212 KB Time limit exceeded
11 Execution timed out 2067 ms 852 KB Time limit exceeded
12 Execution timed out 2081 ms 340 KB Time limit exceeded
13 Execution timed out 2079 ms 3292 KB Time limit exceeded
14 Execution timed out 2088 ms 460 KB Time limit exceeded
15 Execution timed out 2063 ms 1104 KB Time limit exceeded
16 Correct 51 ms 212 KB Output is correct
17 Execution timed out 2086 ms 212 KB Time limit exceeded
18 Execution timed out 2076 ms 460 KB Time limit exceeded
19 Execution timed out 2091 ms 340 KB Time limit exceeded
20 Execution timed out 2083 ms 424 KB Time limit exceeded
21 Execution timed out 2054 ms 852 KB Time limit exceeded
22 Execution timed out 2082 ms 1104 KB Time limit exceeded
23 Execution timed out 2069 ms 4540 KB Time limit exceeded
24 Correct 51 ms 212 KB Output is correct
25 Execution timed out 2083 ms 212 KB Time limit exceeded
26 Execution timed out 2080 ms 340 KB Time limit exceeded
27 Execution timed out 2085 ms 852 KB Time limit exceeded
28 Execution timed out 2087 ms 3332 KB Time limit exceeded
29 Execution timed out 2080 ms 340 KB Time limit exceeded
30 Execution timed out 2079 ms 420 KB Time limit exceeded
31 Execution timed out 2082 ms 1024 KB Time limit exceeded
32 Execution timed out 2072 ms 4412 KB Time limit exceeded
33 Correct 51 ms 288 KB Output is correct
34 Correct 45 ms 212 KB Output is correct
35 Execution timed out 2086 ms 340 KB Time limit exceeded
36 Execution timed out 2082 ms 340 KB Time limit exceeded
37 Execution timed out 2067 ms 724 KB Time limit exceeded
38 Execution timed out 2070 ms 976 KB Time limit exceeded
39 Correct 43 ms 212 KB Output is correct
40 Execution timed out 2052 ms 212 KB Time limit exceeded
41 Execution timed out 2072 ms 340 KB Time limit exceeded
42 Execution timed out 2075 ms 348 KB Time limit exceeded
43 Execution timed out 2077 ms 340 KB Time limit exceeded
44 Execution timed out 2076 ms 596 KB Time limit exceeded
45 Execution timed out 2072 ms 852 KB Time limit exceeded
46 Execution timed out 2082 ms 864 KB Time limit exceeded
47 Execution timed out 2079 ms 5208 KB Time limit exceeded