QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#155312 | #7119. Longest Trip | hos_lyric# | 5 | 332ms | 4036kb | C++14 | 1.9kb | 2023-09-01 15:45:32 | 2023-09-01 15:45:33 |
Judging History
answer
#include "longesttrip.h"
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
// bool are_connected(std::vector<int> A, std::vector<int> B);
std::vector<int> longest_trip(int N, int D)
{
if (D >= 2) {
vector<int> us{0};
for (int u = 1; u < N; ++u) {
vector<int> fs(u);
for (int j = 0; j < u; ++j) {
fs[j] = are_connected({u}, {us[j]});
}
for (int j = 0; j < u - 1; ++j) if (fs[j] && fs[j + 1]) {
us.insert(us.begin() + (j + 1), u);
goto found;
}
{
vector<int> vs{u};
for (int j = 0; j < u; ++j) if (fs[j]) vs.push_back(us[j]);
for (int j = u; --j >= 0; ) if (!fs[j]) vs.push_back(us[j]);
us.swap(vs);
}
found:{}
}
return us;
} else {
assert(false);
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 4020kb
input:
341 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 1 1 3 3 1 1 ...
output:
3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 1 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 1 3 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 1 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0...
result:
ok
Test #2:
score: 0
Accepted
time: 16ms
memory: 4036kb
input:
103 10 3 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 3 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 3 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 3 ...
output:
3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 1 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 2 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 4 1...
result:
ok
Test #3:
score: 0
Accepted
time: 59ms
memory: 4020kb
input:
22 50 3 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 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 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 1 1 1 1 1 ...
output:
3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 1 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 2 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 4 1...
result:
ok
Test #4:
score: 0
Accepted
time: 108ms
memory: 3996kb
input:
8 128 3 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1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C2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 4 1...
result:
ok
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 10
Accepted
time: 11ms
memory: 4016kb
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 1 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 1 3 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 1 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0...
result:
ok
Test #7:
score: 0
Accepted
time: 18ms
memory: 3740kb
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 1 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 2 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 4 1...
result:
ok
Test #8:
score: 0
Accepted
time: 32ms
memory: 3764kb
input:
22 50 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 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 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 1 1 1 1 1 1 ...
output:
3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 1 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 2 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 4 1...
result:
ok
Test #9:
score: 0
Accepted
time: 124ms
memory: 3704kb
input:
8 128 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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kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 4 1...
result:
ok
Test #11:
score: 0
Accepted
time: 11ms
memory: 3780kb
input:
341 3 2 1 0 1 1 3 2 1 1 0 1 3 2 1 1 0 1 3 2 1 1 0 1 3 2 1 0 1 1 3 2 1 1 0 1 3 2 1 1 0 1 3 2 0 1 1 1 3 2 0 1 1 1 3 2 1 1 0 1 3 2 0 1 1 1 3 2 1 1 0 1 3 2 1 0 1 1 3 2 0 1 1 1 3 2 1 1 0 1 3 2 1 1 0 1 3 2 0 1 1 1 3 2 1 1 0 1 3 2 0 1 1 1 3 2 1 1 0 1 3 2 0 1 1 1 3 2 1 1 0 1 3 2 1 0 1 1 3 2 0 1 1 1 3 2 1 0 ...
output:
3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 1 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 1 3 2 0 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 1 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0...
result:
ok
Test #12:
score: -10
Wrong Answer
time: 13ms
memory: 3744kb
input:
103 10 2 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 10 2 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 10 2 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 10 2 ...
output:
3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 1 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 2 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 1 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 2 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 3 0 3kC2Ia2048BfyJVGojMUKKtilctlZKcB 0 1 1 4 1...
result:
wrong answer
Subtask #3:
score: 0
Dangerous Syscalls
Test #19:
score: 0
Dangerous Syscalls
input:
341 3 1
output:
result:
Subtask #4:
score: 0
Dangerous Syscalls
Test #83:
score: 0
Dangerous Syscalls
input:
341 3 1