답안 #1073300

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073300 2024-08-24T11:59:56 Z vjudge1 How to Avoid Disqualification in 75 Easy Steps (CEOI23_avoid) C++17
25 / 100
1 ms 596 KB
#include "avoid.h"
#include <vector>
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;

using ll = long long;
using ld = long double;

//#define int ll
#define sz(x) ((int)(x).size())

using pii = pair<int,int>;
using tii = tuple<int,int,int>;

int cif(int a, int c) {
   return (a & (1 << c)) > 0;
}

std::pair<int, int> scout(int lol, int H) {
   if(lol == 10 && H == 1) {
      for(int i = 0; i < 10; i++) {
         vector<int> a, b;
         for(int j = 1; j <= 1000; j++)
            (!(j & (1 << i))? a : b).emplace_back(j);
         send(a);
      }
      auto T = wait();
      vector<int> uncertain;
      int common = 0;
      for(int i = 0, bit = 0; i < sz(T); bit++, i += 1) {
         common |= (T[i]? 0 : (1 << bit));
      }
      return pii{common,common};
   }
   if(lol == 20 && H == 20) {
      int L = 0, R = 0;
      for(int bit = 0; bit < 10; bit++) {
         vector<int> a;
         for(int i = 1; i <= 1000; i++)
            if((((1 << bit) - 1) & i) == L && (cif(i, bit) == 0)) a.emplace_back(i);
         send(a);
         int t = wait()[0] ^ 1;
         L |= (t << bit);
         a.clear();
         for(int i = 1; i <= 1000; i++)
            if((((1 << bit) - 1) & i) == R && (cif(i, bit) == 1)) a.emplace_back(i);
         send(a);
         t = wait()[0];
         R |= (t << bit);
      }
      return pii{L, R};
   }
   if(lol >= 30 && H >= 2) {
      for(int i = 0; i < 10; i++) {
         vector<int> a, b;
         for(int j = 1; j <= 1000; j++)
            (!(j & (1 << i))? a : b).emplace_back(j);
         send(a);
         send(b);
      }
      auto T = wait();
      vector<int> uncertain;
      int common = 0;
      for(int i = 0, bit = 0; i < sz(T); bit++, i += 2) {
         if(T[i] && T[i + 1]) uncertain.emplace_back(bit);
         else common |= (T[i]? 0 : (1 << bit));
      }
      if(sz(uncertain) == 0) return pii{common, common};
      if(sz(uncertain) == 1) return pii{common, common | (1 << uncertain[0])};
      
      for(int i = 1; i < sz(uncertain); i++) {
         vector<int> a;
         for(int j = 1; j <= 1000; j++) {
            if(cif(j, uncertain[i]) != cif(j, uncertain[i - 1])) a.emplace_back(j);
         }
         send(a);
      }
      
      T = wait();
      int L = common, R = common | (1 << uncertain[0]);
      int how = 0;
      for(int i = 0; i < sz(T); i++) {
         how ^= T[i];
         L |= (how << uncertain[i + 1]);
         R |= ((1 ^ how) << uncertain[i + 1]);
      }
      
      return pii{L, R};
   }
   else {
      
      mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
      vector<int> p(1001), inv = p;
      iota(all(p), 0);
      shuffle(1 + all(p), rng);
      for(int i = 1; i < sz(p); i++) inv[p[i]] = i;
      
      for(int i = 0; i < 10; i++) {
         vector<int> a, b;
         for(int j = 1; j <= 1000; j++)
            (!(j & (1 << i))? a : b).emplace_back(p[j]);
         send(a);
         send(b);
      }
      
      for(int i = 0; i < 10; i++) {
         for(int t = i + 1, C = 0; C < 5 && t < 10; C++, t++) {
            vector<int> a;
            for(int j = 1; j <= 1000; j++) {
               if(cif(j, i) != cif(j, t)) a.emplace_back(p[j]);
            }
            send(a);
         }
      }
      
      auto T = wait();
      vector<int> uncertain;
      int common = 0;
      for(int i = 0, bit = 0; bit < 10; bit++, i += 2) {
         if(T[i] && T[i + 1]) uncertain.emplace_back(bit);
         else common |= (T[i]? 0 : (1 << bit));
      }
      if(sz(uncertain) == 0) return pii{p[common], p[common]};
      if(sz(uncertain) == 1) return pii{p[common], p[common | (1 << uncertain[0])]};
      
      int mat[12][12];
      int ptr = 20;
      for(int i = 0; i < 10; i++) {
         for(int t = i + 1, C = 0; C < 5 && t < 10; C++, t++) {
            mat[i][t] = T[ptr++];
         }
      }
      
      int L = common, R = common | (1 << uncertain[0]);
      int how = 0;
      for(int i = 1; i < sz(uncertain); i++) {
         how ^= mat[uncertain[i - 1]][uncertain[i]];
         L |= (how << uncertain[i]);
         R |= ((1 ^ how) << uncertain[i]);
      }
      
      cerr << common << '\n';
      for(auto x: uncertain) cerr << x << ' ';
      cerr << '\n';
      
      
      return pii{p[L], p[R]};
      
   }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct: 10 robot(s) used, 1 hour(s) passed
2 Correct 0 ms 344 KB Correct: 10 robot(s) used, 1 hour(s) passed
3 Correct 0 ms 344 KB Correct: 10 robot(s) used, 1 hour(s) passed
4 Correct 1 ms 344 KB Correct: 10 robot(s) used, 1 hour(s) passed
5 Correct 0 ms 344 KB Correct: 10 robot(s) used, 1 hour(s) passed
6 Correct 1 ms 344 KB Correct: 10 robot(s) used, 1 hour(s) passed
7 Correct 1 ms 344 KB Correct: 10 robot(s) used, 1 hour(s) passed
8 Correct 0 ms 344 KB Correct: 10 robot(s) used, 1 hour(s) passed
9 Correct 1 ms 344 KB Correct: 10 robot(s) used, 1 hour(s) passed
10 Correct 0 ms 344 KB Correct: 10 robot(s) used, 1 hour(s) passed
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
2 Correct 0 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
3 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
4 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
5 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
6 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
7 Correct 0 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
8 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
9 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
10 Correct 0 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
11 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
12 Correct 1 ms 340 KB Correct: 20 robot(s) used, 20 hour(s) passed
13 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
14 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
15 Correct 0 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
16 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
17 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
18 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
19 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
20 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
21 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
22 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
23 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
24 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
25 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
26 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
27 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
28 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
29 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
30 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
31 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
32 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
33 Correct 0 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
34 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
35 Correct 0 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
36 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
37 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
38 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
39 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
40 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
41 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
42 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
43 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
44 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
45 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
46 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
47 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
48 Correct 0 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
49 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
50 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
51 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
52 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
53 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
54 Correct 0 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
55 Correct 1 ms 344 KB Correct: 20 robot(s) used, 20 hour(s) passed
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
2 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
3 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
4 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
5 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
6 Correct 1 ms 344 KB Correct: 20 robot(s) used, 1 hour(s) passed
7 Correct 1 ms 344 KB Correct: 20 robot(s) used, 1 hour(s) passed
8 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
9 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
10 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
11 Correct 1 ms 344 KB Correct: 29 robot(s) used, 2 hour(s) passed
12 Correct 1 ms 344 KB Correct: 26 robot(s) used, 2 hour(s) passed
13 Correct 1 ms 344 KB Correct: 26 robot(s) used, 2 hour(s) passed
14 Correct 1 ms 344 KB Correct: 26 robot(s) used, 2 hour(s) passed
15 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
16 Correct 0 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
17 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
18 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
19 Correct 1 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
20 Correct 0 ms 344 KB Correct: 20 robot(s) used, 1 hour(s) passed
21 Correct 0 ms 344 KB Correct: 20 robot(s) used, 1 hour(s) passed
22 Correct 1 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
23 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
24 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
25 Correct 0 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
26 Correct 0 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
27 Correct 1 ms 344 KB Correct: 20 robot(s) used, 1 hour(s) passed
28 Correct 0 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
29 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
30 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
31 Correct 1 ms 344 KB Correct: 25 robot(s) used, 2 hour(s) passed
32 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
33 Correct 1 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
34 Correct 1 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
35 Correct 1 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
36 Correct 0 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
37 Correct 1 ms 344 KB Correct: 25 robot(s) used, 2 hour(s) passed
38 Correct 0 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
39 Correct 1 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
40 Correct 0 ms 344 KB Correct: 20 robot(s) used, 1 hour(s) passed
41 Correct 1 ms 596 KB Correct: 23 robot(s) used, 2 hour(s) passed
42 Correct 1 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
43 Correct 1 ms 344 KB Correct: 20 robot(s) used, 1 hour(s) passed
44 Correct 0 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
45 Correct 1 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
46 Correct 1 ms 344 KB Correct: 22 robot(s) used, 2 hour(s) passed
47 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
48 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
49 Correct 1 ms 344 KB Correct: 23 robot(s) used, 2 hour(s) passed
50 Correct 0 ms 344 KB Correct: 20 robot(s) used, 1 hour(s) passed
51 Correct 1 ms 344 KB Correct: 25 robot(s) used, 2 hour(s) passed
52 Correct 1 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
53 Correct 1 ms 344 KB Correct: 21 robot(s) used, 2 hour(s) passed
54 Correct 0 ms 344 KB Correct: 24 robot(s) used, 2 hour(s) passed
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 432 KB Not correct
2 Halted 0 ms 0 KB -