답안 #503178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
503178 2022-01-07T12:45:50 Z leinad2 Minerals (JOI19_minerals) C++17
80 / 100
61 ms 13224 KB
#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>A;
vector<vector<int> >v;
int a;
void solve()
{
    bool flag=true;
    for(int i=0;i<v.size();i++)if(v[i].size()>=2)flag=false;
    if(flag)return;
    int sz=0;
    for(int i=0;i<v.size();i++)
    {
        if(v[i].size()==1)
        {
            sz++;
            continue;
        }
        if(i%2==0)
        {
            for(int j=sz+(v[i].size()+1)/2;j<sz+v[i].size();j++)a=Query(A[j]);
        }
        else
        {
            for(int j=sz;j<sz+(v[i].size())/2;j++)a=Query(A[j]);
        }
        sz+=v[i].size();
    }
    vector<vector<int> >V;
    for(int i=0;i<v.size();i++)
    {
        vector<int>Fi, Se;
        if(v[i].size()==1)
        {
            V.push_back(v[i]);
            continue;
        }
        if(v[i].size()==2)
        {
            int p=v[i][0];
            int b=Query(p);
            if(a!=b)Se.push_back(p),Fi.push_back(v[i][1]);
            else Fi.push_back(p),Se.push_back(v[i][1]);
            a=b;
            V.push_back(Fi);
            V.push_back(Se);
            continue;
        }
        for(auto p:v[i])
        {
            int b=Query(p);
            if(a!=b)Se.push_back(p);
            else Fi.push_back(p);
            a=b;
        }
        V.push_back(Fi);
        V.push_back(Se);
    }
    v=V;
    solve();
}
void Solve(int N)
{
    vector<int>A, B;
    for(int i=1;i<=2*N;i++)
    {
        int b=Query(i);
        if(a!=b)A.push_back(i);
        else B.push_back(i);
        a=b;
    }
    ::A=A;
    v={B};
    solve();
    vector<int>ans;
    for(int i=0;i<v.size();i++)if(v[i].size())ans.push_back(v[i][0]);
    for(int i=0;i<N;i++)Answer(A[i], ans[i]);
}

Compilation message

minerals.cpp: In function 'void solve()':
minerals.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<v.size();i++)if(v[i].size()>=2)flag=false;
      |                 ~^~~~~~~~~
minerals.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
minerals.cpp:22:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             for(int j=sz+(v[i].size()+1)/2;j<sz+v[i].size();j++)a=Query(A[j]);
      |                                            ~^~~~~~~~~~~~~~~
minerals.cpp:26:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             for(int j=sz;j<sz+(v[i].size())/2;j++)a=Query(A[j]);
      |                          ~^~~~~~~~~~~~~~~~~~~
minerals.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:77:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |     for(int i=0;i<v.size();i++)if(v[i].size())ans.push_back(v[i][0]);
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 456 KB Output is correct
2 Correct 3 ms 836 KB Output is correct
3 Correct 4 ms 1352 KB Output is correct
4 Correct 8 ms 2376 KB Output is correct
5 Correct 16 ms 4360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 3 ms 836 KB Output is correct
7 Correct 4 ms 1352 KB Output is correct
8 Correct 8 ms 2376 KB Output is correct
9 Correct 16 ms 4360 KB Output is correct
10 Correct 1 ms 584 KB Output is correct
11 Correct 11 ms 3588 KB Output is correct
12 Correct 15 ms 4360 KB Output is correct
13 Correct 12 ms 4420 KB Output is correct
14 Correct 12 ms 4380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 3 ms 836 KB Output is correct
7 Correct 4 ms 1352 KB Output is correct
8 Correct 8 ms 2376 KB Output is correct
9 Correct 16 ms 4360 KB Output is correct
10 Correct 1 ms 584 KB Output is correct
11 Correct 11 ms 3588 KB Output is correct
12 Correct 15 ms 4360 KB Output is correct
13 Correct 12 ms 4420 KB Output is correct
14 Correct 12 ms 4380 KB Output is correct
15 Correct 48 ms 12760 KB Output is correct
16 Correct 49 ms 12740 KB Output is correct
17 Correct 38 ms 12772 KB Output is correct
18 Correct 37 ms 12676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 3 ms 836 KB Output is correct
7 Correct 4 ms 1352 KB Output is correct
8 Correct 8 ms 2376 KB Output is correct
9 Correct 16 ms 4360 KB Output is correct
10 Correct 1 ms 584 KB Output is correct
11 Correct 11 ms 3588 KB Output is correct
12 Correct 15 ms 4360 KB Output is correct
13 Correct 12 ms 4420 KB Output is correct
14 Correct 12 ms 4380 KB Output is correct
15 Correct 48 ms 12760 KB Output is correct
16 Correct 49 ms 12740 KB Output is correct
17 Correct 38 ms 12772 KB Output is correct
18 Correct 37 ms 12676 KB Output is correct
19 Correct 50 ms 13052 KB Output is correct
20 Correct 51 ms 13008 KB Output is correct
21 Correct 40 ms 13036 KB Output is correct
22 Correct 41 ms 12888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 3 ms 836 KB Output is correct
7 Correct 4 ms 1352 KB Output is correct
8 Correct 8 ms 2376 KB Output is correct
9 Correct 16 ms 4360 KB Output is correct
10 Correct 1 ms 584 KB Output is correct
11 Correct 11 ms 3588 KB Output is correct
12 Correct 15 ms 4360 KB Output is correct
13 Correct 12 ms 4420 KB Output is correct
14 Correct 12 ms 4380 KB Output is correct
15 Correct 48 ms 12760 KB Output is correct
16 Correct 49 ms 12740 KB Output is correct
17 Correct 38 ms 12772 KB Output is correct
18 Correct 37 ms 12676 KB Output is correct
19 Correct 50 ms 13052 KB Output is correct
20 Correct 51 ms 13008 KB Output is correct
21 Correct 40 ms 13036 KB Output is correct
22 Correct 41 ms 12888 KB Output is correct
23 Correct 60 ms 13216 KB Output is correct
24 Correct 45 ms 13224 KB Output is correct
25 Correct 43 ms 13124 KB Output is correct
26 Correct 37 ms 13060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 3 ms 836 KB Output is correct
7 Correct 4 ms 1352 KB Output is correct
8 Correct 8 ms 2376 KB Output is correct
9 Correct 16 ms 4360 KB Output is correct
10 Correct 1 ms 584 KB Output is correct
11 Correct 11 ms 3588 KB Output is correct
12 Correct 15 ms 4360 KB Output is correct
13 Correct 12 ms 4420 KB Output is correct
14 Correct 12 ms 4380 KB Output is correct
15 Correct 48 ms 12760 KB Output is correct
16 Correct 49 ms 12740 KB Output is correct
17 Correct 38 ms 12772 KB Output is correct
18 Correct 37 ms 12676 KB Output is correct
19 Correct 50 ms 13052 KB Output is correct
20 Correct 51 ms 13008 KB Output is correct
21 Correct 40 ms 13036 KB Output is correct
22 Correct 41 ms 12888 KB Output is correct
23 Correct 60 ms 13216 KB Output is correct
24 Correct 45 ms 13224 KB Output is correct
25 Correct 43 ms 13124 KB Output is correct
26 Correct 37 ms 13060 KB Output is correct
27 Incorrect 61 ms 10232 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 3 ms 836 KB Output is correct
7 Correct 4 ms 1352 KB Output is correct
8 Correct 8 ms 2376 KB Output is correct
9 Correct 16 ms 4360 KB Output is correct
10 Correct 1 ms 584 KB Output is correct
11 Correct 11 ms 3588 KB Output is correct
12 Correct 15 ms 4360 KB Output is correct
13 Correct 12 ms 4420 KB Output is correct
14 Correct 12 ms 4380 KB Output is correct
15 Correct 48 ms 12760 KB Output is correct
16 Correct 49 ms 12740 KB Output is correct
17 Correct 38 ms 12772 KB Output is correct
18 Correct 37 ms 12676 KB Output is correct
19 Correct 50 ms 13052 KB Output is correct
20 Correct 51 ms 13008 KB Output is correct
21 Correct 40 ms 13036 KB Output is correct
22 Correct 41 ms 12888 KB Output is correct
23 Correct 60 ms 13216 KB Output is correct
24 Correct 45 ms 13224 KB Output is correct
25 Correct 43 ms 13124 KB Output is correct
26 Correct 37 ms 13060 KB Output is correct
27 Incorrect 61 ms 10232 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 3 ms 836 KB Output is correct
7 Correct 4 ms 1352 KB Output is correct
8 Correct 8 ms 2376 KB Output is correct
9 Correct 16 ms 4360 KB Output is correct
10 Correct 1 ms 584 KB Output is correct
11 Correct 11 ms 3588 KB Output is correct
12 Correct 15 ms 4360 KB Output is correct
13 Correct 12 ms 4420 KB Output is correct
14 Correct 12 ms 4380 KB Output is correct
15 Correct 48 ms 12760 KB Output is correct
16 Correct 49 ms 12740 KB Output is correct
17 Correct 38 ms 12772 KB Output is correct
18 Correct 37 ms 12676 KB Output is correct
19 Correct 50 ms 13052 KB Output is correct
20 Correct 51 ms 13008 KB Output is correct
21 Correct 40 ms 13036 KB Output is correct
22 Correct 41 ms 12888 KB Output is correct
23 Correct 60 ms 13216 KB Output is correct
24 Correct 45 ms 13224 KB Output is correct
25 Correct 43 ms 13124 KB Output is correct
26 Correct 37 ms 13060 KB Output is correct
27 Incorrect 61 ms 10232 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -