답안 #764246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
764246 2023-06-23T09:27:39 Z Dan4Life Minerals (JOI19_minerals) C++17
40 / 100
46 ms 4032 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
int n;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
set<int> S;
void dnc(vector<int> l, vector<int> r, bool d){
    if(sz(l)<1) return;
    if(sz(l)==1) return void(Answer(l[0],r[0]));
    int mid = sz(l)/2, x, tot;
    vector<int> v[2],w[2]; 
    for(int i : {0,1}) v[i].clear(),w[i].clear(); 
    if(d==1){
      for(int i = 0; i < mid; i++) tot=Query(l[i]),S.insert(l[i]);
    }
    else{
      for(int i = mid; i<sz(l); i++) tot=Query(l[i]), S.erase(l[i]);
    }
    for(int i = 0; i < sz(l); i++) v[i>=mid].pb(l[i]);
    shuffle(all(r),rng);
    for(int i : r) x = Query(i), w[x==tot].pb(i), Query(i);
    dnc(v[0],w[0],0);
    for(auto u : S) Query(u); S.clear();
    dnc(v[1],w[1],1);
}
 
void Solve(int N) {
    n = N;
    vector<int> v(2*n,0),w[2],z; int p=0;
    iota(all(v),1); shuffle(all(v),rng);
    for(int i = 0; i < sz(v); i++){
      int x = Query(v[i]);
      if(x!=p) w[0].pb(v[i]), z.pb(v[i]), p=x;
      else w[1].pb(v[i]),p=Query(v[i]);
    }
    dnc(w[0],w[1],1);
}

Compilation message

minerals.cpp: In function 'void dnc(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:27:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   27 |     for(auto u : S) Query(u); S.clear();
      |     ^~~
minerals.cpp:27:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   27 |     for(auto u : S) Query(u); S.clear();
      |                               ^
minerals.cpp:25:37: warning: 'tot' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |     for(int i : r) x = Query(i), w[x==tot].pb(i), Query(i);
      |                                    ~^~~~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 3 ms 464 KB Output is correct
3 Correct 6 ms 592 KB Output is correct
4 Correct 12 ms 976 KB Output is correct
5 Correct 23 ms 1608 KB Output is correct
# 결과 실행 시간 메모리 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 3 ms 464 KB Output is correct
7 Correct 6 ms 592 KB Output is correct
8 Correct 12 ms 976 KB Output is correct
9 Correct 23 ms 1608 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 15 ms 1304 KB Output is correct
12 Correct 29 ms 1704 KB Output is correct
13 Correct 24 ms 1756 KB Output is correct
14 Correct 22 ms 1708 KB Output is correct
# 결과 실행 시간 메모리 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 3 ms 464 KB Output is correct
7 Correct 6 ms 592 KB Output is correct
8 Correct 12 ms 976 KB Output is correct
9 Correct 23 ms 1608 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 15 ms 1304 KB Output is correct
12 Correct 29 ms 1704 KB Output is correct
13 Correct 24 ms 1756 KB Output is correct
14 Correct 22 ms 1708 KB Output is correct
15 Incorrect 46 ms 4032 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 3 ms 464 KB Output is correct
7 Correct 6 ms 592 KB Output is correct
8 Correct 12 ms 976 KB Output is correct
9 Correct 23 ms 1608 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 15 ms 1304 KB Output is correct
12 Correct 29 ms 1704 KB Output is correct
13 Correct 24 ms 1756 KB Output is correct
14 Correct 22 ms 1708 KB Output is correct
15 Incorrect 46 ms 4032 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 3 ms 464 KB Output is correct
7 Correct 6 ms 592 KB Output is correct
8 Correct 12 ms 976 KB Output is correct
9 Correct 23 ms 1608 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 15 ms 1304 KB Output is correct
12 Correct 29 ms 1704 KB Output is correct
13 Correct 24 ms 1756 KB Output is correct
14 Correct 22 ms 1708 KB Output is correct
15 Incorrect 46 ms 4032 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 3 ms 464 KB Output is correct
7 Correct 6 ms 592 KB Output is correct
8 Correct 12 ms 976 KB Output is correct
9 Correct 23 ms 1608 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 15 ms 1304 KB Output is correct
12 Correct 29 ms 1704 KB Output is correct
13 Correct 24 ms 1756 KB Output is correct
14 Correct 22 ms 1708 KB Output is correct
15 Incorrect 46 ms 4032 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 3 ms 464 KB Output is correct
7 Correct 6 ms 592 KB Output is correct
8 Correct 12 ms 976 KB Output is correct
9 Correct 23 ms 1608 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 15 ms 1304 KB Output is correct
12 Correct 29 ms 1704 KB Output is correct
13 Correct 24 ms 1756 KB Output is correct
14 Correct 22 ms 1708 KB Output is correct
15 Incorrect 46 ms 4032 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 3 ms 464 KB Output is correct
7 Correct 6 ms 592 KB Output is correct
8 Correct 12 ms 976 KB Output is correct
9 Correct 23 ms 1608 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 15 ms 1304 KB Output is correct
12 Correct 29 ms 1704 KB Output is correct
13 Correct 24 ms 1756 KB Output is correct
14 Correct 22 ms 1708 KB Output is correct
15 Incorrect 46 ms 4032 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -