QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#553407 | #9239. Hieroglyphs | thomaswmy# | 0 | 58ms | 17596kb | C++14 | 1.9kb | 2024-09-08 12:55:02 | 2024-09-08 12:55:02 |
Judging History
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) {
res.push_back(A[l]);
for(int i:psb[A[l]]) if(i>=r) r=i+1;
l++;
continue;
}
if(cntra==0) {
r++;
continue;
}
if(cntrb==1) {
res.push_back(B[r]);
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;
}
}
return res;
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: 3
Accepted
time: 3ms
memory: 13104kb
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 10 7 1 9 2 3 5 0 6 8 4
result:
ok
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 13360kb
input:
vHwzrZUx9chlYIJ7zODvOcQbZwj3OxhB 10 10 7 9 4 5 6 8 2 1 3 0 7 9 4 5 8 6 2 1 3 0
output:
IyRwUZ9rsuq5tjuK54lpSvORqGQyBWEZ OK 9 7 9 4 5 6 2 1 3 0
result:
wrong answer 3rd lines differ - on the 1st token, expected: '1', found: '9'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 18ms
memory: 17596kb
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 14 187180 47437 27382 67660 103385 8109 76715 71506 77278 155591 25242 62358 165491 128381
result:
wrong answer 3rd lines differ - on the 1st token, expected: '60000', found: '14'
Subtask #3:
score: 0
Time Limit Exceeded
Test #71:
score: 0
Time Limit Exceeded
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:
result:
Subtask #4:
score: 0
Wrong Answer
Test #97:
score: 0
Wrong Answer
time: 58ms
memory: 13920kb
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 39 110955 7003 77556 12701 171483 165117 161693 82544 165639 191736 49075 143290 95615 12313 23610 42920 36085 124043 94305 152453 121345 83096 181427 40325 32407 98034 60069 48187 122046 113266 49921 78832 15378 28982 129401 94912 150349 12080 176459
result:
wrong answer 3rd lines differ - on the 1st token, expected: '20000', found: '39'
Subtask #5:
score: 0
Wrong Answer
Test #132:
score: 0
Wrong Answer
time: 3ms
memory: 13200kb
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 94 182 285 4 31 226 170 290 259 103 203 50 52 222 156 281 10 38 241 178 77 234 154 168 61 76 272 277 193 253 263 177 94 126 23 292 81 17 278 70 133 275 151 3 232 243 159 41 65 287 202 144 155 264 197 194 82 251 172 200 130 13 148 86 26 46 63 109 273 105 89 110 165...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '2800', found: '94'
Subtask #6:
score: 0
Skipped
Dependency #1:
0%