답안 #642769

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
642769 2022-09-20T13:16:20 Z andrei_boaca Abracadabra (CEOI22_abracadabra) C++14
10 / 100
1297 ms 524288 KB
#include <bits/stdc++.h>

using namespace std;
int n,q;
vector<int> v;
vector<vector<int>> vals;
vector<int> trans(vector<int> v)
{
    vector<int> a,b;
    for(int i=0;i<v.size();i++)
    {
        if(i*2<v.size())
            a.push_back(v[i]);
        else
            b.push_back(v[i]);
    }
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    vector<int> rez;
    while(a.size()||b.size())
    {
        if(a.size()&&b.size())
        {
            int x=a.back();
            int y=b.back();
            rez.push_back(min(x,y));
            if(x<y)
                a.pop_back();
            else
                b.pop_back();
            continue;
        }
        if(a.size())
        {
            int x=a.back();
            a.pop_back();
            rez.push_back(x);
        }
        else
        {
            int x=b.back();
            b.pop_back();
            rez.push_back(x);
        }
    }
    return rez;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
    }
    vals.push_back(v);
    while(true)
    {
        v=trans(v);
        vector<int> aux=vals.back();
        bool iseq=1;
        for(int i=0;i<v.size();i++)
            if(v[i]!=aux[i])
                iseq=0;
        if(iseq)
            break;
        vals.push_back(v);
    }
    assert(vals.size()<=n);
    while(q--)
    {
        int i,j;
        cin>>i>>j;
        int lg=vals.size();
        i=min(i,lg-1);
        cout<<vals[i][j-1]<<'\n';
    }
    return 0;
}

Compilation message

Main.cpp: In function 'std::vector<int> trans(std::vector<int>)':
Main.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
Main.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         if(i*2<v.size())
      |            ~~~^~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for(int i=0;i<v.size();i++)
      |                     ~^~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from Main.cpp:1:
Main.cpp:72:23: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   72 |     assert(vals.size()<=n);
      |            ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 283 ms 8636 KB Output is correct
2 Correct 195 ms 5676 KB Output is correct
3 Correct 211 ms 6536 KB Output is correct
4 Correct 179 ms 4628 KB Output is correct
5 Correct 192 ms 5288 KB Output is correct
6 Correct 184 ms 4876 KB Output is correct
7 Correct 237 ms 5456 KB Output is correct
8 Correct 174 ms 4828 KB Output is correct
9 Correct 197 ms 4688 KB Output is correct
10 Correct 179 ms 4812 KB Output is correct
11 Correct 205 ms 4840 KB Output is correct
12 Correct 178 ms 4564 KB Output is correct
13 Correct 191 ms 4592 KB Output is correct
14 Correct 205 ms 5068 KB Output is correct
15 Correct 184 ms 4772 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 179 ms 4700 KB Output is correct
18 Correct 183 ms 4532 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1281 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1297 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 283 ms 8636 KB Output is correct
2 Correct 195 ms 5676 KB Output is correct
3 Correct 211 ms 6536 KB Output is correct
4 Correct 179 ms 4628 KB Output is correct
5 Correct 192 ms 5288 KB Output is correct
6 Correct 184 ms 4876 KB Output is correct
7 Correct 237 ms 5456 KB Output is correct
8 Correct 174 ms 4828 KB Output is correct
9 Correct 197 ms 4688 KB Output is correct
10 Correct 179 ms 4812 KB Output is correct
11 Correct 205 ms 4840 KB Output is correct
12 Correct 178 ms 4564 KB Output is correct
13 Correct 191 ms 4592 KB Output is correct
14 Correct 205 ms 5068 KB Output is correct
15 Correct 184 ms 4772 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 179 ms 4700 KB Output is correct
18 Correct 183 ms 4532 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Runtime error 1281 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -