QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#85435 | #5238. Fotografia [C] | anhduc2701 | 0 | 16ms | 50556kb | C++23 | 2.6kb | 2023-03-07 19:15:04 | 2023-03-07 19:15:07 |
Judging History
answer
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define len(x) (int)(x.size())
#define eb emplace_back
#define PI 3.14159265359
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define BIT(x,i) (1&((x)>>(i)))
#define MASK(x) (1LL<<(x))
#define task "FOT"
typedef long long ll;
const ll INF=1e18;
const int maxn=1e6+5;
const int mod=1e9+7;
const int mo=998244353;
using pi=pair<ll,ll>;
using vi=vector<ll>;
using pii=pair<pair<ll,ll>,ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
int a[maxn];
int ok[maxn];
vector<int>vt;
vector<int>q[maxn];
int st[maxn];
vector<pair<int,int>>ans[maxn];
int k=0;
int pos[maxn];
void dequy(vector<int>q,int ti){
if(len(q)<=1){
return;
}
if(len(q)==2){
k=max(k,1);
ans[ti].pb({q[0],q[1]});
return;
}
k=max(k,ti);
int sz=len(q);
vector<int>d1=q;
for(int i=0;i<q.size();i++){
pos[q[i]]=i;
}
int so=sz-1;
ans[ti+1].pb({q[0],q[1]});
for(int i=1;i<so;i++){
ans[ti].pb({q[i],q[so]});
swap(q[i],q[so]);
so--;
}
for(int i=2;i<q.size();i++){
if(d1[pos[q[i]]+1]>d1[i]){
ans[ti+1].pb({d1[pos[q[i]]+1],d1[i]});
}
}
k=2;
}
signed main()
{
cin.tie(0),cout.tie(0)->sync_with_stdio(0);
// freopen(task".inp" , "r" , stdin);
// freopen(task".out" , "w" , stdout);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
vt.pb(a[i]);
}
sort(vt.begin(),vt.end());
vt.resize(distance(vt.begin(),unique(vt.begin(),vt.end())));
for(int i=1;i<=n;i++){
a[i]=lower_bound(vt.begin(),vt.end(),a[i])-vt.begin()+1;
cout<<a[i]<<" ";
}
cout<<'\n';
int cycle=0;
int d=0;
for(int i=1;i<=n;i++){
if(ok[a[i]]==0){
int x=i;
cycle++;
while(ok[x]==0){
ok[x]=1;
q[cycle].pb(x);
x=a[x];
}
for(auto v:q[cycle]){
cout<<v<<' ';
}
cout<<"\n";
dequy(q[cycle],1);
}
}
cout<<k<<"\n";
for(int i=1;i<=k;i++){
deque<int>de;
for(auto v:ans[i]){
de.push_front(v.fi);
de.push_back(v.se);
}
cout<<de.size()<<"\n";
for(auto v:de){
cout<<v<<" ";
}
cout<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 50300kb
input:
5 138 352 915 1375 2848
output:
1 2 3 4 5 1 2 3 4 5 0
result:
wrong answer you used 1 operation(s) but jury used only 0
Subtask #2:
score: 0
Wrong Answer
Test #18:
score: 0
Wrong Answer
time: 8ms
memory: 50436kb
input:
10 321 457 797 885 892 1367 2480 2742 2767 2955
output:
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 0
result:
wrong answer you used 1 operation(s) but jury used only 0
Subtask #3:
score: 0
Wrong Answer
Test #35:
score: 0
Wrong Answer
time: 13ms
memory: 50396kb
input:
20 29 2902 1870 1908 711 1878 2034 1658 1690 533 1080 689 2282 2637 1599 1912 2365 2015 2659 275
output:
1 20 10 12 5 11 15 8 9 3 6 4 16 18 7 13 17 14 19 2 1 2 20 3 10 4 12 5 6 11 7 15 8 9 13 16 14 18 17 19 1 14 14 13 7 6 4 3 2 20 10 12 11 15 16 18
result:
wrong answer invalid operation #1: duplicated elements
Subtask #4:
score: 0
Wrong Answer
Test #51:
score: 0
Wrong Answer
time: 12ms
memory: 50412kb
input:
100 2985 38 1126 111 1953 886 2186 417 776 326 2961 388 240 1592 1203 1768 581 514 494 2762 1954 641 1731 685 723 1718 1143 761 318 2532 1193 1596 194 2014 2703 2515 2107 1049 2504 1088 1327 102 744 1162 1177 830 2579 461 1362 1100 1273 2471 2077 2628 1541 426 839 1643 1708 732 652 2665 1765 483 191...
output:
99 2 42 4 66 33 74 13 29 10 98 12 8 56 48 64 19 18 17 93 67 22 61 24 25 60 43 28 9 84 46 57 6 68 92 83 73 38 82 40 50 3 27 44 45 31 85 15 51 41 49 79 71 89 55 14 32 58 59 26 23 90 63 16 65 5 21 34 69 70 53 72 37 7 76 75 77 95 52 81 80 39 36 30 47 86 87 88 54 62 91 35 20 94 78 96 100 11 1 97 1 99 2...
result:
wrong answer you used 99 operation(s) but jury used only 1
Subtask #5:
score: 0
Wrong Answer
Test #67:
score: 0
Wrong Answer
time: 10ms
memory: 50392kb
input:
1000 2271 250 4 10 11 13 404 15 1911 2785 308 32 975 2111 1010 2335 2200 1626 45 46 2125 52 53 59 63 2138 2101 837 71 2503 2508 2659 79 542 90 92 299 602 106 2181 159 2167 2550 482 2702 1390 1487 2903 125 1687 129 466 143 279 1319 748 132 148 1141 111 336 164 175 2267 633 186 483 548 946 196 1085 20...
output:
770 88 3 4 5 6 135 8 644 935 108 12 334 716 344 790 742 549 19 20 722 22 23 24 25 727 711 285 29 842 844 900 33 179 35 36 107 202 39 735 60 732 859 160 913 471 507 968 49 575 51 153 57 100 447 252 53 58 385 41 120 62 63 767 209 66 161 181 320 70 372 72 73 985 880 76 529 339 170 910 959 909 83 919 64...
result:
wrong answer you used 770 operation(s) but jury used only 1
Subtask #6:
score: 0
Wrong Answer
Test #78:
score: 0
Wrong Answer
time: 11ms
memory: 50512kb
input:
3000 1 2 3 2029 1711 669 2046 1892 2438 2863 279 12 2604 478 1122 2318 17 497 1969 775 21 2173 865 24 2682 1567 27 551 29 2699 600 32 33 2996 2960 1779 37 38 214 2590 1241 2518 43 1781 2824 390 1384 524 432 50 51 2975 53 406 55 56 57 2188 1410 2578 1447 1060 63 2081 580 2755 67 2560 2722 1071 71 72 ...
output:
1 2 3 2029 1711 669 2046 1892 2438 2863 279 12 2604 478 1122 2318 17 497 1969 775 21 2173 865 24 2682 1567 27 551 29 2699 600 32 33 2996 2960 1779 37 38 214 2590 1241 2518 43 1781 2824 390 1384 524 432 50 51 2975 53 406 55 56 57 2188 1410 2578 1447 1060 63 2081 580 2755 67 2560 2722 1071 71 72 73 74...
result:
wrong answer the array is not sorted
Subtask #7:
score: 0
Wrong Answer
Test #94:
score: 0
Wrong Answer
time: 3ms
memory: 50436kb
input:
3000 729 1498 1848 569 1429 1721 2356 2504 483 158 2104 2471 2942 994 2046 2784 1613 1648 2834 1108 1805 1328 1984 1853 1180 2517 109 2601 2144 30 53 2173 1992 944 121 1595 1943 755 2732 2833 233 2934 1147 1091 2478 1948 252 962 221 400 1235 1486 31 69 1318 804 70 851 1026 930 2731 1922 713 1282 292...
output:
729 1498 1848 569 1429 1721 2356 2504 483 158 2104 2471 2942 994 2046 2784 1613 1648 2834 1108 1805 1328 1984 1853 1180 2517 109 2601 2144 30 53 2173 1992 944 121 1595 1943 755 2732 2833 233 2934 1147 1091 2478 1948 252 962 221 400 1235 1486 31 69 1318 804 70 851 1026 930 2731 1922 713 1282 292 2266...
result:
wrong answer you used 729 operation(s) but jury used only 2
Subtask #8:
score: 0
Wrong Answer
Test #105:
score: 0
Wrong Answer
time: 16ms
memory: 50556kb
input:
3000 766 1622 2731 1980 5 6 200 671 2792 1172 2005 1950 2806 557 2069 2552 1768 2600 2312 346 21 2376 2267 691 2995 26 2319 28 2148 30 970 2779 2645 1580 2627 1900 149 226 1642 1383 928 2575 1648 1859 2203 2701 1100 1391 1745 293 1625 670 1189 54 1413 1733 2878 2501 1765 841 61 454 2372 2901 1420 25...
output:
766 1622 2731 1980 5 6 200 671 2792 1172 2005 1950 2806 557 2069 2552 1768 2600 2312 346 21 2376 2267 691 2995 26 2319 28 2148 30 970 2779 2645 1580 2627 1900 149 226 1642 1383 928 2575 1648 1859 2203 2701 1100 1391 1745 293 1625 670 1189 54 1413 1733 2878 2501 1765 841 61 454 2372 2901 1420 2588 78...
result:
wrong answer you used 766 operation(s) but jury used only 2
Subtask #9:
score: 0
Wrong Answer
Test #116:
score: 0
Wrong Answer
time: 9ms
memory: 50476kb
input:
3000 361 2 3 1184 5 6 7 8 2192 866 1680 935 13 14 618 16 140 18 1462 20 21 600 23 24 749 26 27 28 29 1947 54 2298 33 1313 303 2036 742 723 39 40 41 42 1381 2372 1112 46 2748 2536 49 50 51 52 53 31 1080 2481 57 82 59 2238 1647 62 2271 64 65 2773 67 167 2308 2022 252 794 73 74 2020 916 1141 1461 2287 ...
output:
361 2 3 1184 5 6 7 8 2192 866 1680 935 13 14 618 16 140 18 1462 20 21 600 23 24 749 26 27 28 29 1947 54 2298 33 1313 303 2036 742 723 39 40 41 42 1381 2372 1112 46 2748 2536 49 50 51 52 53 31 1080 2481 57 82 59 2238 1647 62 2271 64 65 2773 67 167 2308 2022 252 794 73 74 2020 916 1141 1461 2287 828 7...
result:
wrong answer you used 361 operation(s) but jury used only 1
Subtask #10:
score: 0
Wrong Answer
Test #132:
score: 0
Wrong Answer
time: 11ms
memory: 50496kb
input:
3000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
wrong answer you used 1 operation(s) but jury used only 0