Submission #1030946

# Submission time Handle Problem Language Result Execution time Memory
1030946 2024-07-22T12:46:10 Z AdamGS Monster Game (JOI21_monster) C++17
100 / 100
72 ms 2160 KB
#include "monster.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
map<pair<int,int>,int>mp;
bool query(int a, int b) {
  if(mp.find({a, b})!=mp.end()) return mp[{a, b}];
  if(Query(a, b)) {
    mp[{a, b}]=1;
    mp[{b, a}]=0;
  } else {
    mp[{b, a}]=1;
    mp[{a, b}]=0;
  }
  return mp[{a, b}];
}
vector<int>cd(vector<int>T) {
  if(T.size()==1) return T;
  vector<int>A, B;
  rep(i, T.size()/2) A.pb(T[i]);
  for(int i=T.size()/2; i<T.size(); ++i) B.pb(T[i]);
  A=cd(A);
  B=cd(B);
  int l1=0, l2=0;
  vector<int>P;
  while(l1<A.size() && l2<B.size()) {
    if(query(A[l1], B[l2])==false) P.pb(A[l1++]);
    else P.pb(B[l2++]);
  }
  while(l1<A.size()) P.pb(A[l1++]);
  while(l2<B.size()) P.pb(B[l2++]);
  return P;
}
vector<int>Solve(int n) {
  vector<int>T(n);
  rep(i, n) T[i]=i;
  T=cd(T);
  string s="";
  if(query(T[0], T[2])) s+="1"; else s+="0";
  if(query(T[0], T[3])) s+="1"; else s+="0";
  if(query(T[1], T[3])) s+="1"; else s+="0";
  int l=0;
  if(s=="001" || s=="011" || s=="101") {
    l=1;
  } else if(s=="000" || s=="010") {
    reverse(T.begin(), T.begin()+2);
    l=2;
  } else if(s=="110") {
    reverse(T.begin(), T.begin()+3);
    l=3;
  } else if(s=="111") {
    l=4;
    while(l<n) {
      if(query(T[l-2], T[l])==false) break;
      ++l;
    }
    reverse(T.begin(), T.begin()+l);
  } else {
    l=4;
    while(l<n) {
      if(query(T[0], T[l])==true) {
        swap(T[0], T[2]);
        break;
      }
      if(query(T[1], T[l])==true) {
        swap(T[1], T[2]);
        break;
      }
      if(query(T[2], T[l])==true) {
        swap(T[0], T[1]);
        break;
      }
      ++l;
    }
    ++l;
    reverse(T.begin()+3, T.begin()+l);
  }
  while(l<n) {
    int p=l;
    while(query(T[l-1], T[p])==false) ++p;
    reverse(T.begin()+l, T.begin()+p+1);
    l=p+1;
  }
  vector<int>P(n);
  rep(i, n) P[T[i]]=i;
  return P;
}

Compilation message

monster.cpp: In function 'std::vector<int> cd(std::vector<int>)':
monster.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
monster.cpp:24:3: note: in expansion of macro 'rep'
   24 |   rep(i, T.size()/2) A.pb(T[i]);
      |   ^~~
monster.cpp:25:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for(int i=T.size()/2; i<T.size(); ++i) B.pb(T[i]);
      |                         ~^~~~~~~~~
monster.cpp:30:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   while(l1<A.size() && l2<B.size()) {
      |         ~~^~~~~~~~~
monster.cpp:30:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   while(l1<A.size() && l2<B.size()) {
      |                        ~~^~~~~~~~~
monster.cpp:34:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   while(l1<A.size()) P.pb(A[l1++]);
      |         ~~^~~~~~~~~
monster.cpp:35:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   while(l2<B.size()) P.pb(B[l2++]);
      |         ~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 10 ms 600 KB Output is correct
18 Correct 7 ms 600 KB Output is correct
19 Correct 7 ms 600 KB Output is correct
20 Correct 7 ms 544 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 5 ms 600 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 6 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 10 ms 600 KB Output is correct
18 Correct 7 ms 600 KB Output is correct
19 Correct 7 ms 600 KB Output is correct
20 Correct 7 ms 544 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 5 ms 600 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 6 ms 344 KB Output is correct
33 Correct 58 ms 1356 KB Output is correct
34 Correct 66 ms 1616 KB Output is correct
35 Correct 59 ms 1584 KB Output is correct
36 Correct 52 ms 1360 KB Output is correct
37 Correct 55 ms 1748 KB Output is correct
38 Correct 60 ms 1544 KB Output is correct
39 Correct 53 ms 2160 KB Output is correct
40 Correct 49 ms 1912 KB Output is correct
41 Correct 47 ms 1616 KB Output is correct
42 Correct 47 ms 1360 KB Output is correct
43 Correct 29 ms 1112 KB Output is correct
44 Correct 35 ms 1044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 1544 KB Output is correct
2 Correct 68 ms 1360 KB Output is correct
3 Correct 55 ms 1644 KB Output is correct
4 Correct 59 ms 1616 KB Output is correct
5 Correct 51 ms 1560 KB Output is correct
6 Correct 56 ms 1704 KB Output is correct
7 Correct 46 ms 1200 KB Output is correct
8 Correct 51 ms 1512 KB Output is correct
9 Correct 51 ms 1592 KB Output is correct
10 Correct 62 ms 1760 KB Output is correct
11 Correct 55 ms 1884 KB Output is correct
12 Correct 54 ms 1572 KB Output is correct
13 Correct 51 ms 1188 KB Output is correct
14 Correct 40 ms 1428 KB Output is correct
15 Correct 35 ms 1792 KB Output is correct
16 Correct 28 ms 968 KB Output is correct
17 Correct 72 ms 1396 KB Output is correct
18 Correct 30 ms 1104 KB Output is correct