Submission #662128

# Submission time Handle Problem Language Result Execution time Memory
662128 2022-11-26T07:03:22 Z victor_gao Monster Game (JOI21_monster) C++17
0 / 100
83 ms 316 KB
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC optimize("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include "monster.h"
#include<bits/stdc++.h>
#define pii pair<int,int>
#define x first
#define y second
using namespace std;

vector<int> Merge(vector<int>now){
  if (now.size()<=1) return now;
  int n=now.size();
  int mid=(n-1)/2;
  vector<int>l,r;
  for (int i=0;i<=mid;i++)
    l.push_back(now[i]);
  for (int i=mid+1;i<n;i++)
    r.push_back(now[i]);
  vector<int>al=Merge(l);
  vector<int>ar=Merge(r);
  vector<int>ans;
  int p=0;
  for (int i=0;i<al.size();i++){
    if (p<ar.size()){
      if (Query(al[i],ar[p])){
        ans.push_back(ar[p]);
        p++; i--;
      }
      else ans.push_back(al[i]);
    }
    else ans.push_back(al[i]);
  }
  while (p<ar.size()){
    ans.push_back(ar[p]);
    p++;
  }
  return ans;
}
vector<int> Solve1(vector<int>vt){
    map<pii,vector<int> >mp;
    vector<int>ans;
    int cnt[10]={0},N=vt.size();
    ans.resize(N,0);
    for (int i=0;i<N;i++){
        for (int j=i+1;j<N;j++){
            if (Query(vt[i],vt[j])) cnt[i]++;
            else cnt[j]++;
        }
    }
    for (int i=0;i<N;i++)
        mp[{cnt[i],N-1-cnt[i]}].push_back(i);
    for (auto i:mp){
        if (i.y.size()==1){
          ans[i.x.x]=vt[i.y[0]];
        }
        else {
            int a=vt[i.y[0]],b=vt[i.y[1]];
            if (Query(a,b)){
                if (i.x.x<N/2){
                    ans[i.x.x-1]=a;
                    ans[i.x.x]=b;
                }
                else {
                  ans[i.x.x]=a;
                  ans[i.x.x+1]=b;
                }
            } 
            else {
                if (i.x.x<N/2){
                    ans[i.x.x-1]=b;
                    ans[i.x.x]=a;
                }
                else {
                  ans[i.x.x]=b;
                  ans[i.x.x+1]=a;
                }
            }
        } 
    }
    return ans;
}
vector<int> Solve(int N){
    vector<int>now;
    for (int i=0;i<N;i++)
      now.push_back(i);
    vector<int>ans=Merge(now);
    for (int i=0;i<N;i++){
      vector<int>out;
      for (int j=i;j<N&&(j-i<=5);j++)
        out.push_back(ans[j]);
      if (out.size()<=3) break;
      out=Solve1(out);
      for (int j=i;j<N&&(j-i<=5);j++)
        ans[j]=out[j-i];
    }
    vector<int>tans;
    tans.resize(N,0);
    for (int i=0;i<N;i++)
      tans[ans[i]]=i;
    return tans;
}

Compilation message

monster.cpp: In function 'std::vector<int> Merge(std::vector<int>)':
monster.cpp:23:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   for (int i=0;i<al.size();i++){
      |                ~^~~~~~~~~~
monster.cpp:24:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     if (p<ar.size()){
      |         ~^~~~~~~~~~
monster.cpp:33:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   while (p<ar.size()){
      |          ~^~~~~~~~~~
# 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 1 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 1 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 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 2 ms 208 KB Output is correct
15 Incorrect 1 ms 208 KB Wrong Answer [3]
16 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 1 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 1 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 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 2 ms 208 KB Output is correct
15 Incorrect 1 ms 208 KB Wrong Answer [3]
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 316 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -