QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#812606#67. Two Transportationsguleng2007#0 2ms4240kbC++203.4kb2024-12-13 17:03:132024-12-13 17:03:13

Judging History

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

  • [2024-12-13 17:03:13]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:4240kb
  • [2024-12-13 17:03:13]
  • 提交

Azer

#include "Azer.h"
#include <bits/stdc++.h>
using namespace std;

const int N=2005;

namespace
{

vector <int> g[N], w[N];
int d[N], n, bestval, val, cur;
bool vis[N], trans;

int getbest()
{
	int best=0;
	for(int j=1;j<=n;j++)
		if(!vis[j] && (!best || d[j]<d[best]))
			best=j;
	return best;
}

int lastval()
{
	int Max=0;
	for(int i=1;i<=n;i++)
		if(vis[i])
			Max=max(Max,d[i]);
	return Max;
}

void report_val(int val)
{
	val=min(val-lastval(),511);
	for(int i=8;i>=0;i--)
		SendA((val>>i)&1), cur++;
}

void report_id(int val)
{
	for(int i=10;i>=0;i--)
		SendA((val>>i)&1), cur++;
}

}

void ReceiveA(bool x)
{
	val=val*2+x, cur++;
	if(!trans && cur==9)
	{
		int best=getbest();
		report_val(d[best]);
		if(d[best]<=val)
		{
			report_id(best);
			vis[best]=true;
			trans=false, cur=0, val=0;
		}
		else
			trans=true, bestval=val, val=0;
		return;
	}

	if(trans && cur==18)
	{
		int best=getbest();
		if(d[best]<=val)
		{
			report_id(best);
			vis[best]=true;
			trans=false, cur=0, val=0;
		}
		else
			trans=true, bestval=val, val=0;
		return;
	}

	if(trans && cur==29)
	{
		d[val]=bestval+lastval();
		vis[val]=true;
		trans=false, cur=0, val=0;
		return;
	}
}

void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C)
{
	n=N;
	int m=V.size();
	for(int i=0;i<m;i++)
	{
		g[U[i]+1].push_back(V[i]+1);
		g[V[i]+1].push_back(U[i]+1);
		w[U[i]+1].push_back(C[i]);
		w[V[i]+1].push_back(C[i]);
	}

	memset(d,0x3f,sizeof(d));
	d[1]=0, vis[1]=true;
	for(int i=0;i<g[1].size();i++)
		d[g[1][i]]=min(d[g[1][i]],d[1]+w[1][i]);

	if(n==1)
		return;

	trans=true, report_val(d[getbest()]);
}

vector <int> Answer()
{
	vector <int> ans;
	for(int i=1;i<=n;i++)
		ans.push_back(d[i]);
	return ans;
}

Baijan

#include "Baijan.h"
#include <bits/stdc++.h>
using namespace std;

const int N=2005;

namespace
{

vector <int> g[N], w[N];
int d[N], n, bestval, val, cur;
bool vis[N], trans;

int getbest()
{
	int best=0;
	for(int j=1;j<=n;j++)
		if(!vis[j] && (!best || d[j]<d[best]))
			best=j;
	return best;
}

int lastval()
{
	int Max=0;
	for(int i=1;i<=n;i++)
		if(vis[i])
			Max=max(Max,d[i]);
	return Max;
}

void report_val(int val)
{
	val=min(val-lastval(),511);
	for(int i=8;i>=0;i--)
		SendB((val>>i)&1), cur++;
}

void report_id(int val)
{
	for(int i=10;i>=0;i--)
		SendB((val>>i)&1), cur++;
}

}

void ReceiveB(bool x)
{
	val=val*2+x, cur++;
	if(!trans && cur==9)
	{
		int best=getbest();
		report_val(d[best]);
		if(d[best]<val)
		{
			report_id(best);
			vis[best]=true;
			trans=false, cur=0, val=0;
		}
		else
			trans=true, bestval=val, val=0;
		return;
	}

	if(trans && cur==18)
	{
		int best=getbest();
		if(d[best]<val)
		{
			report_id(best);
			vis[best]=true;
			trans=false, cur=0, val=0;
		}
		else
			trans=true, bestval=val, val=0;
		return;
	}

	if(trans && cur==29)
	{
		d[val]=bestval+lastval();
		vis[val]=true;
		trans=false, cur=0, val=0;
		return;
	}
}

void InitB(int N, int B, vector<int> U, vector<int> V, vector<int> C)
{
	n=N;
	int m=V.size();
	for(int i=0;i<m;i++)
	{
		g[U[i]+1].push_back(V[i]+1);
		g[V[i]+1].push_back(U[i]+1);
		w[U[i]+1].push_back(C[i]);
		w[V[i]+1].push_back(C[i]);
	}

	memset(d,0x3f,sizeof(d));
	d[1]=0, vis[1]=true;
	for(int i=0;i<g[1].size();i++)
		d[g[1][i]]=min(d[g[1][i]],d[1]+w[1][i]);

	if(n==1)
		return;
}

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: 4076kb

input:

1 1 1 1 1 1 1 1 1 -1
-1
-1

output:

-1
0 1 0 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 -1
-1

input:


output:

0
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1...

result:

wrong answer 2nd lines differ - expected: '2417', found: '1061109567'

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 8
Accepted
time: 1ms
memory: 3960kb

input:

-1

output:

-1
-1

input:


output:

0

result:

ok single line: '0'

Test #8:

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

input:

1 1 1 1 1 1 1 1 1 -1
-1
-1

output:

-1
0 1 1 0 1 0 1 0 1 0 0 1 0 0 1 1 1 0 0 1 -1
-1

input:


output:

0
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1...

result:

wrong answer 2nd lines differ - expected: '128264', found: '1061109567'

Subtask #3:

score: 0
Wrong Answer

Test #14:

score: 0
Wrong Answer
time: 0ms
memory: 4080kb

input:

1 0 0 1 1 1 0 0 1 -1
0 0 0 0 1 1 1 0 1 0 0 -1
-1

output:

-1
1 1 0 1 0 0 1 0 1 -1
-1
-1

input:


output:

0
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
392
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
10611095...

result:

wrong answer 2nd lines differ - expected: '3328', found: '1061109567'

Subtask #4:

score: 0
Wrong Answer

Test #24:

score: 0
Wrong Answer
time: 1ms
memory: 4240kb

input:

1 1 1 1 1 1 1 1 1 -1
-1
-1

output:

-1
0 1 0 0 1 0 0 1 1 0 0 1 1 0 0 1 0 0 1 0 -1
-1

input:


output:

0
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1...

result:

wrong answer 2nd lines differ - expected: '1881', found: '1061109567'

Subtask #5:

score: 0
Wrong Answer

Test #38:

score: 0
Wrong Answer
time: 0ms
memory: 4224kb

input:

0 0 1 0 1 1 1 1 0 -1
0 1 1 1 0 1 1 1 1 0 1 -1
-1

output:

-1
1 1 1 1 1 1 1 1 1 -1
-1
-1

input:


output:

0
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1...

result:

wrong answer 2nd lines differ - expected: '3467', found: '1061109567'

Subtask #6:

score: 0
Wrong Answer

Test #51:

score: 0
Wrong Answer
time: 1ms
memory: 3984kb

input:

1 1 1 1 1 1 1 1 1 -1
-1
-1

output:

-1
0 1 0 1 1 0 0 0 0 0 1 0 1 0 1 1 1 1 1 0 -1
-1

input:


output:

0
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1...

result:

wrong answer 2nd lines differ - expected: '4745', found: '1061109567'

Subtask #7:

score: 0
Wrong Answer

Test #64:

score: 0
Wrong Answer
time: 0ms
memory: 4124kb

input:

1 1 1 1 1 0 0 0 0 -1
1 0 0 0 1 1 1 0 1 0 1 -1
-1

output:

-1
1 1 1 1 1 0 0 1 1 -1
-1
-1

input:


output:

0
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1061109567
1...

result:

wrong answer 2nd lines differ - expected: '25855', found: '1061109567'