Submission #628986

# Submission time Handle Problem Language Result Execution time Memory
628986 2022-08-13T22:31:38 Z welleyth Minerals (JOI19_minerals) C++17
40 / 100
19 ms 2124 KB
#include "minerals.h"
#include <vector>
#include <fstream>

void Solve(int N) {
    int col[2*N+1];
    for(int i = 0; i < 2*N+1; i++){
        col[i] = 0;
    }
    int c = 0;
    int in[N+1];
    for(int i = 0; i <= N; i++)
        in[i] = 0;
    int pos[N+1];
    bool is[2*N+1];
    bool was[2*N+1];
    for(int i = 0; i <= 2*N; i++) in[i] = was[i] = false;
    int sz = 0;
    int mx[2*N+1];
    for(int i = 0; i <= 2*N; i++) mx[i] = 0;
    for(int i = 1; i <= 2*N; i++){
        int cur = Query(i);
        if(cur != sz){
            sz = cur;
            pos[cur] = i;
            is[i] = 1;
            in[cur] = 1;
            col[i] = sz;
            was[i] = true;
        } else {
            sz = Query(i);
        }
        mx[i] = sz;
    }
    for(int bt = 0; (1 << bt) <= N; bt++){
        for(int i = 1; i <= N; i++){
            if(in[i] && (i >> bt & 1) == 0){
                sz = Query(pos[i]);
                in[i] = false;
            }
            if(!in[i] && (i >> bt & 1) == 1){
                sz = Query(pos[i]);
                in[i] = true;
            }
        }
        for(int i = 1; i <= 2*N; i++){
            if(was[i] || mx[i] < (1 << bt))
                continue;
            int nw = Query(i);
            if(nw == sz){
                col[i] |= (1 << bt);
            }
            sz = Query(i);
        }
    }
    std::vector<int> A[N+1];
    for(int i = 1; i <= 2*N; i++){
        A[col[i]].push_back(i);
    }
    for(int i = 1; i <= N; i++){
        Answer(A[i][0],A[i][1]);
    }
    return;
}
/**
4
1 5
2 6
3 4
7 8

**/

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:10:9: warning: unused variable 'c' [-Wunused-variable]
   10 |     int c = 0;
      |         ^
minerals.cpp:15:10: warning: variable 'is' set but not used [-Wunused-but-set-variable]
   15 |     bool is[2*N+1];
      |          ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 3 ms 720 KB Output is correct
4 Correct 6 ms 1116 KB Output is correct
5 Correct 11 ms 1872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 1116 KB Output is correct
9 Correct 11 ms 1872 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 9 ms 1304 KB Output is correct
12 Correct 13 ms 1872 KB Output is correct
13 Correct 11 ms 2040 KB Output is correct
14 Correct 8 ms 1880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 1116 KB Output is correct
9 Correct 11 ms 1872 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 9 ms 1304 KB Output is correct
12 Correct 13 ms 1872 KB Output is correct
13 Correct 11 ms 2040 KB Output is correct
14 Correct 8 ms 1880 KB Output is correct
15 Incorrect 19 ms 2124 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 1116 KB Output is correct
9 Correct 11 ms 1872 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 9 ms 1304 KB Output is correct
12 Correct 13 ms 1872 KB Output is correct
13 Correct 11 ms 2040 KB Output is correct
14 Correct 8 ms 1880 KB Output is correct
15 Incorrect 19 ms 2124 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 1116 KB Output is correct
9 Correct 11 ms 1872 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 9 ms 1304 KB Output is correct
12 Correct 13 ms 1872 KB Output is correct
13 Correct 11 ms 2040 KB Output is correct
14 Correct 8 ms 1880 KB Output is correct
15 Incorrect 19 ms 2124 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 1116 KB Output is correct
9 Correct 11 ms 1872 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 9 ms 1304 KB Output is correct
12 Correct 13 ms 1872 KB Output is correct
13 Correct 11 ms 2040 KB Output is correct
14 Correct 8 ms 1880 KB Output is correct
15 Incorrect 19 ms 2124 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 1116 KB Output is correct
9 Correct 11 ms 1872 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 9 ms 1304 KB Output is correct
12 Correct 13 ms 1872 KB Output is correct
13 Correct 11 ms 2040 KB Output is correct
14 Correct 8 ms 1880 KB Output is correct
15 Incorrect 19 ms 2124 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 6 ms 1116 KB Output is correct
9 Correct 11 ms 1872 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 9 ms 1304 KB Output is correct
12 Correct 13 ms 1872 KB Output is correct
13 Correct 11 ms 2040 KB Output is correct
14 Correct 8 ms 1880 KB Output is correct
15 Incorrect 19 ms 2124 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -