Submission #602972

# Submission time Handle Problem Language Result Execution time Memory
602972 2022-07-23T13:34:24 Z Ahmadsm2005 Art Collections (BOI22_art) C++17
50 / 100
949 ms 668 KB
#include "art.h"
#include <bits/stdc++.h>
//
// --- Sample implementation for the task art ---
//
// To compile this program with the sample grader, place:
//     art.h art_sample.cpp sample_grader.cpp
// in a single folder, then open the terminal in this directory (right-click onto an empty spot in the directory,
// left click on "Open in terminal") and enter e.g.:
//     g++ -std=c++17 art_sample.cpp sample_grader.cpp
// in this folder. This will create a file a.out in the current directory which you can execute from the terminal
// as ./a.out
// See task statement or sample_grader.cpp for the input specification
//
using namespace std;
vector<int>GLOB;
vector<int>resolve(vector<int>A,vector<int>B){
int S1 = 0, S2 = 0;
int LST = publish(GLOB);
vector<int>FF;
while(S1 < A.size() && S2 < B.size()){
    swap(GLOB[A[S1]],GLOB[B[S2]]);
    int F1 = publish(GLOB);
    swap(GLOB[A[S1]],GLOB[B[S2]]);
    if(F1 < LST){
    FF.push_back(GLOB[B[S2]]);
    S2++;
    }
    else
    FF.push_back(GLOB[A[S1]]),S1++;
}
while(S1 < A.size())FF.push_back(GLOB[A[S1]]),S1++;
while(S2 < B.size())FF.push_back(GLOB[B[S2]]),S2++;
//cout<<A[0]<<' '<<B[0]<<endl;
//for(int i = 0; i < B.size(); i += 1)cout<<B[i]<<' ';
//cout<<endl;
vector<int>RE = A;
for(int i = 0; i < B.size(); i += 1)RE.push_back(B[i]);
for(int i = 0; i < RE.size(); i += 1){
    GLOB[RE[i]] = FF[i];
}
return RE;
}
void solve(int N) {
    GLOB.clear();
    for(int i = 0; i < N; i += 1)GLOB.push_back(i + 1);
    vector<vector<int>>NEW,TEMP;
    for(int i = 0; i < N; i += 1){
        vector<int>EE;
        EE.push_back(i);
        NEW.push_back(EE);
    }
    while(NEW.size() > 1){
        for(int i = 0; i < NEW.size() - 1; i += 2){
            TEMP.push_back(resolve(NEW[i],NEW[i + 1]));
        }
        if(NEW.size() % 2)TEMP.push_back(NEW.back());
        NEW = TEMP;
        //cout<<NEW.size()<<endl;
        TEMP.clear();
    }
    answer(GLOB);
}

Compilation message

art.cpp: In function 'std::vector<int> resolve(std::vector<int>, std::vector<int>)':
art.cpp:21:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 | while(S1 < A.size() && S2 < B.size()){
      |       ~~~^~~~~~~~~~
art.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 | while(S1 < A.size() && S2 < B.size()){
      |                        ~~~^~~~~~~~~~
art.cpp:32:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 | while(S1 < A.size())FF.push_back(GLOB[A[S1]]),S1++;
      |       ~~~^~~~~~~~~~
art.cpp:33:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 | while(S2 < B.size())FF.push_back(GLOB[B[S2]]),S2++;
      |       ~~~^~~~~~~~~~
art.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 | for(int i = 0; i < B.size(); i += 1)RE.push_back(B[i]);
      |                ~~^~~~~~~~~~
art.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 | for(int i = 0; i < RE.size(); i += 1){
      |                ~~^~~~~~~~~~~
art.cpp: In function 'void solve(int)':
art.cpp:54:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int i = 0; i < NEW.size() - 1; i += 2){
      |                        ~~^~~~~~~~~~~~~~~~
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 208 KB Output is correct
10 Correct 4 ms 308 KB Output is correct
11 Correct 4 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 3 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 208 KB Output is correct
10 Correct 4 ms 308 KB Output is correct
11 Correct 4 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 3 ms 304 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 4 ms 208 KB Output is correct
23 Correct 4 ms 208 KB Output is correct
24 Correct 3 ms 208 KB Output is correct
25 Correct 2 ms 208 KB Output is correct
26 Correct 52 ms 308 KB Output is correct
27 Correct 59 ms 336 KB Output is correct
28 Correct 72 ms 308 KB Output is correct
29 Correct 77 ms 316 KB Output is correct
30 Correct 78 ms 320 KB Output is correct
31 Correct 70 ms 312 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Correct 1 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 3 ms 208 KB Output is correct
39 Correct 2 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 208 KB Output is correct
10 Correct 4 ms 308 KB Output is correct
11 Correct 4 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 3 ms 304 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 4 ms 208 KB Output is correct
23 Correct 4 ms 208 KB Output is correct
24 Correct 3 ms 208 KB Output is correct
25 Correct 2 ms 208 KB Output is correct
26 Correct 52 ms 308 KB Output is correct
27 Correct 59 ms 336 KB Output is correct
28 Correct 72 ms 308 KB Output is correct
29 Correct 77 ms 316 KB Output is correct
30 Correct 78 ms 320 KB Output is correct
31 Correct 70 ms 312 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Correct 1 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 3 ms 208 KB Output is correct
39 Correct 2 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 4 ms 208 KB Output is correct
42 Correct 3 ms 208 KB Output is correct
43 Correct 3 ms 208 KB Output is correct
44 Correct 3 ms 208 KB Output is correct
45 Correct 59 ms 300 KB Output is correct
46 Correct 44 ms 336 KB Output is correct
47 Correct 71 ms 432 KB Output is correct
48 Correct 83 ms 308 KB Output is correct
49 Correct 68 ms 316 KB Output is correct
50 Correct 71 ms 304 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Correct 170 ms 336 KB Output is correct
53 Correct 127 ms 208 KB Output is correct
54 Correct 200 ms 316 KB Output is correct
55 Correct 225 ms 336 KB Output is correct
56 Correct 202 ms 336 KB Output is correct
57 Correct 220 ms 332 KB Output is correct
58 Correct 0 ms 208 KB Output is correct
59 Correct 0 ms 208 KB Output is correct
60 Correct 1 ms 208 KB Output is correct
61 Correct 1 ms 208 KB Output is correct
62 Correct 0 ms 208 KB Output is correct
63 Correct 2 ms 208 KB Output is correct
64 Correct 3 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 208 KB Output is correct
10 Correct 4 ms 308 KB Output is correct
11 Correct 4 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 3 ms 304 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 4 ms 208 KB Output is correct
23 Correct 4 ms 208 KB Output is correct
24 Correct 3 ms 208 KB Output is correct
25 Correct 2 ms 208 KB Output is correct
26 Correct 52 ms 308 KB Output is correct
27 Correct 59 ms 336 KB Output is correct
28 Correct 72 ms 308 KB Output is correct
29 Correct 77 ms 316 KB Output is correct
30 Correct 78 ms 320 KB Output is correct
31 Correct 70 ms 312 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Correct 1 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 3 ms 208 KB Output is correct
39 Correct 2 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 4 ms 208 KB Output is correct
42 Correct 3 ms 208 KB Output is correct
43 Correct 3 ms 208 KB Output is correct
44 Correct 3 ms 208 KB Output is correct
45 Correct 59 ms 300 KB Output is correct
46 Correct 44 ms 336 KB Output is correct
47 Correct 71 ms 432 KB Output is correct
48 Correct 83 ms 308 KB Output is correct
49 Correct 68 ms 316 KB Output is correct
50 Correct 71 ms 304 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Correct 170 ms 336 KB Output is correct
53 Correct 127 ms 208 KB Output is correct
54 Correct 200 ms 316 KB Output is correct
55 Correct 225 ms 336 KB Output is correct
56 Correct 202 ms 336 KB Output is correct
57 Correct 220 ms 332 KB Output is correct
58 Correct 0 ms 208 KB Output is correct
59 Correct 0 ms 208 KB Output is correct
60 Correct 1 ms 208 KB Output is correct
61 Correct 1 ms 208 KB Output is correct
62 Correct 0 ms 208 KB Output is correct
63 Correct 2 ms 208 KB Output is correct
64 Correct 3 ms 300 KB Output is correct
65 Correct 1 ms 208 KB Output is correct
66 Correct 4 ms 208 KB Output is correct
67 Correct 3 ms 336 KB Output is correct
68 Correct 4 ms 208 KB Output is correct
69 Correct 4 ms 208 KB Output is correct
70 Correct 45 ms 304 KB Output is correct
71 Correct 42 ms 316 KB Output is correct
72 Correct 66 ms 208 KB Output is correct
73 Correct 74 ms 320 KB Output is correct
74 Correct 75 ms 320 KB Output is correct
75 Correct 90 ms 308 KB Output is correct
76 Correct 0 ms 208 KB Output is correct
77 Correct 151 ms 320 KB Output is correct
78 Correct 136 ms 208 KB Output is correct
79 Correct 243 ms 340 KB Output is correct
80 Correct 234 ms 328 KB Output is correct
81 Correct 209 ms 208 KB Output is correct
82 Correct 213 ms 208 KB Output is correct
83 Incorrect 949 ms 668 KB Not correct
84 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 3 ms 208 KB Output is correct
10 Correct 4 ms 308 KB Output is correct
11 Correct 4 ms 208 KB Output is correct
12 Correct 5 ms 208 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 2 ms 208 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 208 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 3 ms 208 KB Output is correct
20 Correct 3 ms 304 KB Output is correct
21 Correct 0 ms 208 KB Output is correct
22 Correct 4 ms 208 KB Output is correct
23 Correct 4 ms 208 KB Output is correct
24 Correct 3 ms 208 KB Output is correct
25 Correct 2 ms 208 KB Output is correct
26 Correct 52 ms 308 KB Output is correct
27 Correct 59 ms 336 KB Output is correct
28 Correct 72 ms 308 KB Output is correct
29 Correct 77 ms 316 KB Output is correct
30 Correct 78 ms 320 KB Output is correct
31 Correct 70 ms 312 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 0 ms 208 KB Output is correct
34 Correct 1 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 208 KB Output is correct
37 Correct 1 ms 208 KB Output is correct
38 Correct 3 ms 208 KB Output is correct
39 Correct 2 ms 208 KB Output is correct
40 Correct 0 ms 208 KB Output is correct
41 Correct 4 ms 208 KB Output is correct
42 Correct 3 ms 208 KB Output is correct
43 Correct 3 ms 208 KB Output is correct
44 Correct 3 ms 208 KB Output is correct
45 Correct 59 ms 300 KB Output is correct
46 Correct 44 ms 336 KB Output is correct
47 Correct 71 ms 432 KB Output is correct
48 Correct 83 ms 308 KB Output is correct
49 Correct 68 ms 316 KB Output is correct
50 Correct 71 ms 304 KB Output is correct
51 Correct 0 ms 208 KB Output is correct
52 Correct 170 ms 336 KB Output is correct
53 Correct 127 ms 208 KB Output is correct
54 Correct 200 ms 316 KB Output is correct
55 Correct 225 ms 336 KB Output is correct
56 Correct 202 ms 336 KB Output is correct
57 Correct 220 ms 332 KB Output is correct
58 Correct 0 ms 208 KB Output is correct
59 Correct 0 ms 208 KB Output is correct
60 Correct 1 ms 208 KB Output is correct
61 Correct 1 ms 208 KB Output is correct
62 Correct 0 ms 208 KB Output is correct
63 Correct 2 ms 208 KB Output is correct
64 Correct 3 ms 300 KB Output is correct
65 Correct 1 ms 208 KB Output is correct
66 Correct 4 ms 208 KB Output is correct
67 Correct 3 ms 336 KB Output is correct
68 Correct 4 ms 208 KB Output is correct
69 Correct 4 ms 208 KB Output is correct
70 Correct 45 ms 304 KB Output is correct
71 Correct 42 ms 316 KB Output is correct
72 Correct 66 ms 208 KB Output is correct
73 Correct 74 ms 320 KB Output is correct
74 Correct 75 ms 320 KB Output is correct
75 Correct 90 ms 308 KB Output is correct
76 Correct 0 ms 208 KB Output is correct
77 Correct 151 ms 320 KB Output is correct
78 Correct 136 ms 208 KB Output is correct
79 Correct 243 ms 340 KB Output is correct
80 Correct 234 ms 328 KB Output is correct
81 Correct 209 ms 208 KB Output is correct
82 Correct 213 ms 208 KB Output is correct
83 Incorrect 949 ms 668 KB Not correct
84 Halted 0 ms 0 KB -