Submission #784431

# Submission time Handle Problem Language Result Execution time Memory
784431 2023-07-16T06:19:40 Z canadavid1 Archery (IOI09_archery) C++14
21 / 100
2000 ms 5180 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++)
        {
            while(i > 4*N && i < R-N) i+=N; // unsure of this bound
            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:36: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]
   36 |             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 12 ms 304 KB Output is correct
4 Execution timed out 2074 ms 340 KB Time limit exceeded
5 Correct 1 ms 212 KB Output is correct
6 Correct 124 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 106 ms 212 KB Output is correct
3 Execution timed out 2071 ms 340 KB Time limit exceeded
4 Execution timed out 2081 ms 724 KB Time limit exceeded
5 Execution timed out 2080 ms 4540 KB Time limit exceeded
6 Correct 81 ms 296 KB Output is correct
7 Execution timed out 2076 ms 212 KB Time limit exceeded
8 Execution timed out 2084 ms 724 KB Time limit exceeded
9 Execution timed out 2083 ms 988 KB Time limit exceeded
10 Execution timed out 2086 ms 212 KB Time limit exceeded
11 Execution timed out 2065 ms 1000 KB Time limit exceeded
12 Execution timed out 2076 ms 340 KB Time limit exceeded
13 Execution timed out 2054 ms 3424 KB Time limit exceeded
14 Execution timed out 2066 ms 472 KB Time limit exceeded
15 Execution timed out 2064 ms 1232 KB Time limit exceeded
16 Correct 90 ms 212 KB Output is correct
17 Execution timed out 2074 ms 340 KB Time limit exceeded
18 Execution timed out 2084 ms 340 KB Time limit exceeded
19 Execution timed out 2083 ms 408 KB Time limit exceeded
20 Execution timed out 2085 ms 468 KB Time limit exceeded
21 Execution timed out 2081 ms 944 KB Time limit exceeded
22 Execution timed out 2084 ms 1224 KB Time limit exceeded
23 Execution timed out 2070 ms 4656 KB Time limit exceeded
24 Correct 51 ms 288 KB Output is correct
25 Execution timed out 2060 ms 212 KB Time limit exceeded
26 Execution timed out 2072 ms 468 KB Time limit exceeded
27 Execution timed out 2061 ms 1028 KB Time limit exceeded
28 Execution timed out 2062 ms 3520 KB Time limit exceeded
29 Execution timed out 2079 ms 340 KB Time limit exceeded
30 Execution timed out 2080 ms 468 KB Time limit exceeded
31 Execution timed out 2088 ms 980 KB Time limit exceeded
32 Execution timed out 2074 ms 4592 KB Time limit exceeded
33 Correct 74 ms 212 KB Output is correct
34 Correct 85 ms 300 KB Output is correct
35 Execution timed out 2070 ms 364 KB Time limit exceeded
36 Execution timed out 2069 ms 340 KB Time limit exceeded
37 Execution timed out 2081 ms 852 KB Time limit exceeded
38 Execution timed out 2057 ms 1104 KB Time limit exceeded
39 Correct 78 ms 284 KB Output is correct
40 Execution timed out 2062 ms 212 KB Time limit exceeded
41 Execution timed out 2072 ms 340 KB Time limit exceeded
42 Execution timed out 2065 ms 340 KB Time limit exceeded
43 Execution timed out 2017 ms 472 KB Time limit exceeded
44 Execution timed out 2065 ms 608 KB Time limit exceeded
45 Execution timed out 2040 ms 980 KB Time limit exceeded
46 Execution timed out 2035 ms 980 KB Time limit exceeded
47 Execution timed out 2077 ms 5180 KB Time limit exceeded