QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#458485 | #8838. Jesse's Job | ucup-team956# | WA | 1ms | 3652kb | C++20 | 1.5kb | 2024-06-29 17:36:25 | 2024-06-29 17:36:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define time chrono::system_clock::now().time_since_epoch().count()
mt19937_64 rnd(time);
#define maxn 1000005
#define int long long
int read() {int x;cin>>x;return x;}
void solve() {
int n = read(), res = n;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++) a[i] = read();
vector<int> vis(n + 1);
int pos = 1, cnt = 0;
vector<int> an;
while(!vis[pos]) {
vis[pos] = 1; cnt += 1;
pos = a[pos];
an.push_back(pos);
}
if(cnt != n) {
cout << n << "\n";
cout << cnt << "\n";
for(auto i : an) cout << i << " ";
cout << "\n";
return;
}
for(int i = 1; i <= n; i++) {
int x = a[i], y = i;
int ans = abs(x - y);
res = min(res, ans);
if(ans == 0) {
cout << n << "\n";
cout << 1 << "\n";
cout << y << "\n";
return;
}
}
for(int i = 1; i <= n; i++) {
int x = a[i], y = i;
int ans = abs(x - y);
if(ans == res) {
cout << n - res - 1 << "\n";
cout << 1 << "\n";
cout << y << "\n";
return;
}
}
}
signed main() {
#ifdef ONLINE_JUDGE
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
#else
//freopen("a.in", "r", stdin);
#endif
int t = read();
while(t--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
input:
3 2 2 1 4 2 1 4 3 6 3 5 4 2 6 1
output:
0 1 1 4 2 2 1 4 1 3
result:
ok Correct (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3652kb
input:
872 6 1 5 2 6 3 4 6 5 2 1 3 4 6 4 2 1 3 4 6 2 3 1 4 5 6 6 4 5 1 6 2 3 6 6 2 3 1 4 5 5 2 1 3 4 5 6 1 2 6 4 3 5 4 2 1 4 3 6 1 6 4 2 5 3 6 6 1 3 5 4 2 6 2 1 4 5 6 3 6 3 4 1 5 6 2 6 4 1 5 3 2 6 6 5 2 1 6 3 4 6 4 1 6 2 5 3 6 5 1 3 6 2 4 6 6 2 5 4 3 1 6 6 2 5 3 1 4 6 5 2 4 1 3 6 6 6 1 3 2 4 5 6 2 3 4 6 5 ...
output:
6 1 1 6 4 5 4 3 1 4 2 2 1 6 3 2 3 1 6 4 4 6 3 1 6 4 6 5 4 1 5 2 2 1 6 1 1 4 2 2 1 6 1 1 6 3 6 2 1 6 2 2 1 6 2 3 1 6 5 4 3 5 2 1 6 3 5 3 1 6 3 4 2 1 6 3 5 2 1 6 2 6 1 6 5 6 4 3 5 1 6 4 5 3 4 1 6 5 6 5 4 2 1 6 5 2 3 4 6 1 6 5 5 3 2 6 1 6 2 4 1 4 1 2 6 2 3 1 6 1 1 6 1 1 6 1 1...
result:
wrong answer Jury found better answer than participant (test case 143)