QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#491306 | #9155. 集合 | spdarkle | 100 ✓ | 212ms | 89148kb | C++14 | 1.6kb | 2024-07-25 18:38:32 | 2024-07-25 18:38:35 |
Judging History
answer
/*
先对P做一个最长下降得到f[i]
然后因为要求字典序严格大于
所以直接
*/
#include<bits/stdc++.h>
using namespace std;
#define N 1050500
#define int long long
#define ull unsigned long long
int n,m,q,mnl[N];
ull rk[N],a[N],b[N],vala[N],valb[N];
ull sa,sb;
vector<int>numa[N],numb[N];
void add(int pos){
for(auto x:numa[pos])sa-=vala[x];
for(auto x:numb[pos])sb-=valb[x];
for(auto x:numa[pos])vala[x]^=rk[pos];
for(auto x:numb[pos])valb[x]^=rk[pos];
for(auto x:numa[pos])sa+=vala[x];
for(auto x:numb[pos])sb+=valb[x];
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n>>m>>q;
mt19937_64 rnd(998244353);
for(int i=1;i<=max(n,m);i++)rk[i]=rnd();/*内层随机赋权然后求和,外层直接xor*/
for(int i=1;i<=n;i++){
int x,y,z;cin>>x>>y>>z;
numa[i].push_back(x);numa[i].push_back(y);numa[i].push_back(z);
// a[i]=rk[x]+rk[y]+rk[z];
}
for(int i=1;i<=n;i++){
int x,y,z;cin>>x>>y>>z;
numb[i].push_back(z);numb[i].push_back(y);numb[i].push_back(x);
// b[i]=rk[x]+rk[y]+rk[z];
}
/*
充要条件:对于任意数 x
其在A中在集合c_1~c_m中都出现了
那么有一个一一对应的y,其在B中集合c_1~c_m都出现了
所以可以对于每个数维护其出现序列
我们考虑给每个位置一个随机值
然后对于一个数,如果在这个位置出现,那么其出现序列异或上它
最后我们将所有数的异或值求和
*/
for(int i=1,l=1;i<=n;i++){
add(i);
while(sa!=sb&&l<=i)add(l),++l;
mnl[i]=l;
}
while(q--){
int l,r;cin>>l>>r;
if(l>=mnl[r])cout<<"Yes\n";
else cout<<"No\n";
}
}
Details
Pretests
Pretest #1:
score: 5
Accepted
time: 14ms
memory: 58344kb
Pretest #2:
score: 5
Accepted
time: 3ms
memory: 58936kb
Pretest #3:
score: 5
Accepted
time: 6ms
memory: 57500kb
Pretest #4:
score: 5
Accepted
time: 0ms
memory: 57776kb
Pretest #5:
score: 5
Accepted
time: 3ms
memory: 57844kb
Pretest #6:
score: 5
Accepted
time: 4ms
memory: 57172kb
Pretest #7:
score: 5
Accepted
time: 7ms
memory: 57444kb
Pretest #8:
score: 5
Accepted
time: 4ms
memory: 57560kb
Pretest #9:
score: 5
Accepted
time: 20ms
memory: 59008kb
Pretest #10:
score: 5
Accepted
time: 12ms
memory: 58188kb
Pretest #11:
score: 5
Accepted
time: 95ms
memory: 77544kb
Pretest #12:
score: 5
Accepted
time: 91ms
memory: 80124kb
Pretest #13:
score: 5
Accepted
time: 0ms
memory: 58720kb
Pretest #14:
score: 5
Accepted
time: 7ms
memory: 57784kb
Pretest #15:
score: 5
Accepted
time: 104ms
memory: 59056kb
Pretest #16:
score: 5
Accepted
time: 106ms
memory: 59208kb
Pretest #17:
score: 5
Accepted
time: 13ms
memory: 59968kb
Pretest #18:
score: 5
Accepted
time: 11ms
memory: 60676kb
Pretest #19:
score: 5
Accepted
time: 211ms
memory: 80832kb
Pretest #20:
score: 5
Accepted
time: 211ms
memory: 89120kb
Final Tests
Test #1:
score: 5
Accepted
time: 3ms
memory: 57832kb
Test #2:
score: 5
Accepted
time: 4ms
memory: 57208kb
Test #3:
score: 5
Accepted
time: 4ms
memory: 57028kb
Test #4:
score: 5
Accepted
time: 4ms
memory: 57744kb
Test #5:
score: 5
Accepted
time: 4ms
memory: 58944kb
Test #6:
score: 5
Accepted
time: 4ms
memory: 57104kb
Test #7:
score: 5
Accepted
time: 4ms
memory: 58328kb
Test #8:
score: 5
Accepted
time: 0ms
memory: 59000kb
Test #9:
score: 5
Accepted
time: 23ms
memory: 57024kb
Test #10:
score: 5
Accepted
time: 20ms
memory: 58632kb
Test #11:
score: 5
Accepted
time: 71ms
memory: 77764kb
Test #12:
score: 5
Accepted
time: 89ms
memory: 75716kb
Test #13:
score: 5
Accepted
time: 3ms
memory: 58584kb
Test #14:
score: 5
Accepted
time: 4ms
memory: 57424kb
Test #15:
score: 5
Accepted
time: 108ms
memory: 57676kb
Test #16:
score: 5
Accepted
time: 96ms
memory: 58652kb
Test #17:
score: 5
Accepted
time: 10ms
memory: 58800kb
Test #18:
score: 5
Accepted
time: 15ms
memory: 61172kb
Test #19:
score: 5
Accepted
time: 208ms
memory: 75772kb
Test #20:
score: 5
Accepted
time: 212ms
memory: 89148kb
Extra Test:
score: 0
Extra Test Passed