QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#177439#7119. Longest Triptriple321#0 7ms4092kbC++201.2kb2023-09-12 23:13:152024-04-28 08:41:38

Judging History

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

  • [2024-04-28 08:41:38]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:7ms
  • 内存:4092kb
  • [2023-09-12 23:13:16]
  • 评测
  • 测评结果:0
  • 用时:7ms
  • 内存:4128kb
  • [2023-09-12 23:13:15]
  • 提交

answer

#include "longesttrip.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")

using namespace std;
using namespace __gnu_pbds;

#define lg long long
#define ordered_set	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


vector<lg> adj[257];
vector<int> ans, cur;
lg vis[257];

void dfs(lg src)
{
	vis[src] = true;
	// cout << "ENTER " << src << '\n';
	cur.push_back(src);
	if(cur.size() > (lg)ans.size())	ans = cur;
	for(auto it : adj[src])
	{
		if(vis[it])	continue;
		dfs(it);
	}
	cur.pop_back();
	// cout << "LEAVE " << src << '\n';
	vis[src] = false;
	return;
}

std::vector<int> longest_trip(int n, int d)
{
	for(int i = 0; i < n; i++)	adj[i].clear();
	ans.clear();
	for(int i = 0; i < n; i++)
	{
		for(int j = i+1; j < n; j++)
		{
			bool b = are_connected({i}, {j});
			if(b)
			{
				adj[i].push_back(j);
				adj[j].push_back(i);
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		dfs(i);
		// cout << '\n';
	}
    return ans;
}
/*
1
5 1
1
1 1
0 0 1
0 0 0 1
*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 5
Accepted
time: 0ms
memory: 3872kb

input:

341
3 3
1
1
1
1
3 3
1
1
1
1
3 3
1
1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 1 0 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 7...

result:


Subtask #2:

score: 0
Time Limit Exceeded

Test #6:

score: 10
Accepted
time: 4ms
memory: 3792kb

input:

341
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
1
1
3 2
1
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 2...

result:

ok 

Test #7:

score: -10
Time Limit Exceeded

input:

103
10 2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10 2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10 2
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 7...

result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #19:

score: 25
Accepted
time: 0ms
memory: 3800kb

input:

341
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 2...

result:

ok 

Test #20:

score: -25
Time Limit Exceeded

input:

103
10 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 7...

result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #83:

score: 60
Accepted
time: 7ms
memory: 4092kb

input:

341
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
1
1
3 1
1
1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
1 3 0 1 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 1 2...

result:

ok 

Test #84:

score: 0
Time Limit Exceeded

input:

103
10 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10 1
...

output:

3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 1
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 2
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 3
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 4
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 5
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 6
3kC2Ia2048BfyJVGojMUKKtilctlZKcB
0 1 1 0 7...

result: