QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#736704 | #5660. Simplified Genome Translation | SanguineChameleon# | RE | 0ms | 0kb | C++20 | 3.0kb | 2024-11-12 12:45:58 | 2024-11-12 12:45:58 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define vi vector<int>
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i=a;i<(b);++i)
typedef pair<int,int> pii;
bool dfs(int a,int L, vector<vi>& g,vi& btoa, vi& A, vi& B){
if(A[a] != L)return 0;
A[a] = -1;
for(int b:g[a]) if(B[b]==L+1){
B[b]=0;
if(btoa[b] == -1 || dfs(btoa[b], L+1, g, btoa, A, B)){
return btoa[b]=a, 1;
}
}
return 0;
}
int hK(vector<vi>& g, vi& btoa) {
int res=0;
vi A(g.size()), B(btoa.size()), cur, next;
for(;;){
fill(all(A), 0);
fill(all(B), 0);
for(int a:btoa) if (a!= -1) A[a]=-1;
rep(a,0,g.size())if(A[a]==0)cur.pb(a);
for(int lay=1;;lay++){
bool isLast=0;
next.clear();
for(int a:cur){
for(int b:g[a]){
if(btoa[b]==-1){
B[b]=lay;
isLast=1;
}else if(btoa[b]!=a && !B[b]){
B[b]=lay;
next.pb(btoa[b]);
}
}
}
if(isLast)break;
if(next.empty())return res;
for(int a:next)A[a] = lay;
cur.swap(next);
}
rep(a,0,g.size()){
res+= dfs(a,0,g,btoa,A,B);
}
}
}
const int mxn=50005;
pair<pii,pii> gt[mxn],dd[mxn];
int area[mxn];
vi grid[2005][2005];
void solve(){
int m,n;
cin>>m>>n;
for(int i=0;i<m;i++){//gt
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
gt[i]={mp(x1,y1),mp(x2,y2)};
area[i] = (x2-x1)*(y2-y1);
for(int x=x1;x<=x2;x++){
for(int y=y1;y<=y2;y++){
grid[x][y].pb(i);
}
}
}
vector<vi> g;
for(int i=0;i<n;i++){//detected
int x1,y1,x2,y2;
vi cur;
cin>>x1>>y1>>x2>>y2;
dd[i]={mp(x1,y1),mp(x2,y2)};
vi merged;
for(int x=x1;x<=x2;x++){
for(int y=y1;y<=y2;y++){
for(int ele:grid[x][y])merged.pb(ele);
}
}
sort(merged.begin(),merged.end());
merged.erase(unique(merged.begin(),merged.end()),merged.end());
for(int id:merged){
//d n g / g >= 1/2 --> d n g >= 2*g
int nx1=max(x1,gt[id].f.f);
int nx2=min(x2,gt[id].f.s);
int ny1=max(y1,gt[id].s.f);
int ny2=min(y2,gt[id].s.s);
if((nx2-nx1)*(ny2-ny1) >= 2 * area[id]){
//add edge
cur.pb(id);
}
}
g.pb(cur);
}
vi btoa(m,-1);
cout<<hK(g,btoa)<<'\n';
}
int32_t main() {
ios_base::sync_with_stdio(false);cin.tie(0);
int tc;
cin>>tc;
while(tc--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
5 UUUUAACACUUUAUCACUUAACACCAC CAAAAUAUGAAAAAU AUGUACUUUGCGUUUCACUAA UUGCACUACUAC UACGUGGGUAUC