QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#645403 | #7157. Bikes vs Cars | yanshanjiahong | 0 | 4ms | 10456kb | C++14 | 2.5kb | 2024-10-16 18:10:25 | 2024-10-16 18:10:25 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define ls(x) (x<<1)
#define rs(x) ((x<<1)|1)
#define mp make_pair
#define sec second
#define fir first
#define pii pair<int,int>
#define lowbit(i) i&-i
#define int long long
#define double long double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=505,M=5e5+5,S=(1<<15)+5,inf=(ll)1e18+7,mo=1e9+7;
const double eps=1e-8;
void read(int &p){
int x=0,w=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-')w=-1;
ch=getchar();
}
while(isdigit(ch)){
x=(x<<1)+(x<<3)+ch-'0';
ch=getchar();
}
p=x*w;
}
int n,w,b[N][N],c[N][N],cntb,cntc;
struct edge{
int x,y,v;
friend bool operator<(edge x,edge y){
return x.v>y.v;
}
}eb[N],ec[N];
vector<edge>ans;
int valb[N][N],valc[N][N];
struct bcj{
int fa[N];
void init(){
rep(i,1,n)
fa[i]=i;
}
int find(int x){
if(fa[x]==x)return x;
return fa[x]=find(fa[x]);
}
bool merge(int x,int y){
x=find(x),y=find(y);
if(x==y)return 0;
fa[x]=y;
return 1;
}
}B;
signed main(){
read(n),read(w);
rep(j,2,n){
rep(i,1,j-1)
read(c[i][j]),ec[++cntc]=(edge){i,j,c[i][j]};
}
rep(j,2,n){
rep(i,1,j-1)
read(b[i][j]),eb[++cntb]=(edge){i,j,b[i][j]};
}
sort(eb+1,eb+cntb+1),sort(ec+1,ec+cntc+1);
rep(i,1,n){
rep(j,1,n)
valb[i][j]=valc[i][j]=0;
}
B.init();
rep(i,1,cntb){
int x=eb[i].x,y=eb[i].y,v=eb[i].v;
if(c[x][y]+v<w)continue;
if(B.merge(x,y))ans.push_back((edge){x,y,v}),valb[x][y]=valb[y][x]=v;
}
B.init();
rep(i,1,cntc){
int x=ec[i].x,y=ec[i].y,v=ec[i].v;
if(b[x][y]+v<w)continue;
if(B.merge(x,y))ans.push_back((edge){x,y,w-v}),valc[x][y]=valc[y][x]=v;
}
rep(k,1,n){
rep(i,1,n){
rep(j,1,n){
valb[i][j]=max(valb[i][j],min(valb[i][k],valb[k][j]));
valc[i][j]=max(valc[i][j],min(valc[i][k],valc[k][j]));
}
}
}
bool ok=1;
rep(i,1,n){
rep(j,i+1,n)
if(valb[i][j]!=b[i][j]||valc[i][j]!=c[i][j])ok=0;
}
if(!ok)puts("NO");
else{
printf("%lld\n",ans.size());
for(auto j:ans)
printf("%lld %lld %lld\n",j.x-1,j.y-1,j.v);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 10120kb
input:
14 1000000 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 49...
output:
26 1 11 536641 1 12 536641 0 12 536641 10 11 536641 9 11 536641 8 11 536641 7 11 536641 6 11 536641 5 11 536641 4 11 536641 3 11 536641 2 11 536641 1 13 536641 1 11 505815 1 12 505815 0 12 505815 10 11 505815 9 11 505815 8 11 505815 7 11 505815 6 11 505815 5 11 505815 4 11 505815 3 11 505815 2 11 50...
result:
ok
Test #2:
score: 10
Accepted
time: 2ms
memory: 9996kb
input:
37 1000000 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 89...
output:
NO
result:
ok
Test #3:
score: 0
Wrong Answer
time: 2ms
memory: 9948kb
input:
40 1000000 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 82...
output:
NO
result:
wrong answer Contestant said no, judge found solution
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #16:
score: 17
Accepted
time: 1ms
memory: 7988kb
input:
14 1000000 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 494185 49...
output:
26 1 11 536641 1 12 536641 0 12 536641 10 11 536641 9 11 536641 8 11 536641 7 11 536641 6 11 536641 5 11 536641 4 11 536641 3 11 536641 2 11 536641 1 13 536641 1 11 505815 1 12 505815 0 12 505815 10 11 505815 9 11 505815 8 11 505815 7 11 505815 6 11 505815 5 11 505815 4 11 505815 3 11 505815 2 11 50...
result:
ok
Test #17:
score: 17
Accepted
time: 0ms
memory: 9932kb
input:
37 1000000 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 891050 89...
output:
NO
result:
ok
Test #18:
score: 0
Wrong Answer
time: 2ms
memory: 10004kb
input:
40 1000000 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 824509 82...
output:
NO
result:
wrong answer Contestant said no, judge found solution
Subtask #4:
score: 0
Wrong Answer
Test #39:
score: 0
Wrong Answer
time: 4ms
memory: 10456kb
input:
163 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 ...
output:
NO
result:
wrong answer Contestant said no, judge found solution
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%