C
题目链接:https://codeforces.com/contest/1746/problem/C
此题着实不难,就是看你自己能不能想到那种构造的方法。自己做的时候没有很好的思路,所以参考了官方的解析()。
个人觉得官方解析不错,一步一步来的蛮好。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<iostream> 2 #include<cstdio> 3 #include<string> 4 #include<cstring> 5 #include<algorithm> 6 #include<cmath> 7 #include<map> 8 #include<vector> 9 #define ll long long 10 #define ull unsigned long long 11 #define mem(x,y) memset(x,y,sizeof(x)) 12 //#define int long long 13 14 inline ll read() 15 { 16 ll x=0,f=1;char ch=getchar(); 17 while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();} 18 while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();} 19 return x*f; 20 } 21 22 using namespace std; 23 const int maxm=1e5+5,inf=0x3f3f3f3f; 24 int n,a[maxm],b[maxm]; 25 26 void solve(){ 27 cin>>n; 28 for(int i=1;i<=n;++i) cin>>a[i]; 29 int p=1; 30 for(int i=1;i<=n;++i){ 31 b[a[i]]=i; 32 } 33 for(int i=1;i<n;++i){ 34 if(b[i]!=n) 35 cout<<b[i]+1<<' '; 36 else cout<<1<<' '; 37 } 38 if(b[n]!=n) cout<<b[n]+1<<endl; 39 else cout<<1<<endl; 40 return ; 41 } 42 43 signed main(){ 44 // ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); 45 int _=1; 46 cin>>_; 47 while(_--){ 48 solve(); 49 } 50 return 0; 51 }View Code
标签:ch,23,int,ll,Global,Codeforces,long,include,define From: https://www.cnblogs.com/Qiansui/p/16810756.html