QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#553401#9239. Hieroglyphsthomaswmy#0 27ms18432kbC++141.9kb2024-09-08 12:52:402024-09-08 12:52:41

Judging History

你现在查看的是最新测评结果

  • [2024-09-08 12:52:41]
  • 评测
  • 测评结果:0
  • 用时:27ms
  • 内存:18432kb
  • [2024-09-08 12:52:40]
  • 提交

answer

#include <bits/stdc++.h>
#include "hieroglyphs.h"
using namespace std;
const int N=2e5+10;

int n,m;
vector<int> psa[N],psb[N];

struct BIT{
  int t[N];

  int lowbit(int x) {
    return x&-x;
  }

  void change(int pos,int val) {
    pos++;
    for(;pos<N;pos+=lowbit(pos)) t[pos]+=val;
  }

  int sum(int pos) {
    pos++;
    int res=0;
    for(;pos;pos-=lowbit(pos)) res+=t[pos];
    return res;
  }

  int query(int l,int r) {
    return sum(r)-sum(l-1);
  }
}bit;

vector<int> ucs(vector<int> A,vector<int> B) {
  n=A.size(),m=B.size();
  vector<int> res;
  for(int i=0;i<n;i++) psa[A[i]].push_back(i);
  for(int i=0;i<m;i++) psb[B[i]].push_back(i);
  int l=0,r=0;
  while(l<n && r<m) {
    int cntla=0,cntlb=0;
    for(int i:psa[A[l]]) if(i>=l) cntla++;
    for(int i:psb[A[l]]) if(i>=r) cntlb++;
    int cntra=0,cntrb=0;
    for(int i:psa[B[r]]) if(i>=l) cntra++;
    for(int i:psb[B[r]]) if(i>=r) cntrb++;
    if(cntlb==0) {
      l++;
      continue;
    }
    if(cntla==1) {
      for(int i:psb[A[l]]) if(i>=r) r=i+1;
      l++;
      continue;
    }
    if(cntra==0) {
      r++;
      continue;
    }
    if(cntrb==1) {
      for(int i:psa[B[r]]) if(i>=l) l=i+1;
      r++;
      continue;
    }
    if(psb[A[l]][0]<=psb[B[r]][1]) {
      r++;
      continue;
    }
    else {
      l++;
      continue;
    }
  }
  int cnt=0;
  for(int i=0;i<=2e5;i++) if(psa[i].size() && psb[i].size()) cnt++;
  for(int i=0;i<n;i++) {
    if(psa[A[i]].size()+psb[A[i]].size()==3) {
      if(psa[A[i]].size() && psb[A[i]].size()) {
        if(psa[A[i]].size()==1) {
          if(bit.query(psb[A[i]][0],psb[A[i]][1])) return {-1};
        }
        else {
          if(i==psa[A[i]][0]) bit.change(psb[A[i]][0],1);
          else bit.change(psb[A[i]][0],-1);
        }
      }
    }
  }
  if(res.size()!=cnt) return {-1};
  return res;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 13176kb

input:

vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB
10 10
7 1 9 2 3 5 0 6 8 4
7 1 9 2 3 5 0 6 8 4

output:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
1
-1

result:

wrong answer 3rd lines differ - on the 1st token, expected: '10', found: '1'

Subtask #2:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 27ms
memory: 18432kb

input:

vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB
89984 90016
167910 187180 47437 150113 199404 61979 49501 155514 167910 175137 104441 149717 155514 13573 170025 181983 117868 13573 149717 166954 145922 29787 93788 58581 158693 51768 120499 17700 17700 4746 119328 33450 138501 137246 33450 135751 84363 168724 15701...

output:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
1
-1

result:

wrong answer 3rd lines differ - on the 1st token, expected: '60000', found: '1'

Subtask #3:

score: 0
Wrong Answer

Test #71:

score: 0
Wrong Answer
time: 12ms
memory: 15792kb

input:

vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB
100000 100000
0 1 0 0 1 1 1 1 0 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 0 1 1 0 1 1 0 0 0 1 1 0 0 1 0 0 1 1 0 0 0 0 0 1 1 1 0 1 0 0 0 1 0 1 0 1 1 1 1 0 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 0 0 1 1 0 1 1 1 0 1 0...

output:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
1
-1

result:

wrong answer 3rd lines differ - on the 1st token, expected: '85671', found: '1'

Subtask #4:

score: 0
Wrong Answer

Test #97:

score: 0
Wrong Answer
time: 2ms
memory: 13944kb

input:

vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB
20000 30000
110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110955 110...

output:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
1
-1

result:

wrong answer 3rd lines differ - on the 1st token, expected: '20000', found: '1'

Subtask #5:

score: 0
Wrong Answer

Test #132:

score: 0
Wrong Answer
time: 2ms
memory: 13620kb

input:

vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB
2800 2999
47 51 42 122 38 125 170 11 119 48 289 297 27 150 207 271 11 15 67 287 149 220 76 274 128 151 60 117 39 123 254 75 170 198 72 179 274 203 13 88 139 153 46 288 13 282 16 219 284 91 274 63 190 157 72 286 238 1 219 82 82 31 285 128 198 172 161 271 36 111 160 26...

output:

IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ
OK
1
-1

result:

wrong answer 3rd lines differ - on the 1st token, expected: '2800', found: '1'

Subtask #6:

score: 0
Skipped

Dependency #1:

0%