sol:根一定是第一个, 然后不太会,去看了洛谷题解
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; #define fi first #define se second #define fz1(i,n) for ((i)=1;(i)<=(n);(i)++) #define fd1(i,n) for ((i)=(n);(i)>=1;(i)--) #define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++) #define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--) #define fz0k(i,n) for ((i)=0;(i)<(n);(i)++) #define fd0k(i,n) for ((i)=(((long long)(n))-1);(i)>=0;(i)--) #define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++) #define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--) #define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr) #define pb push_back #define mp make_pair #define inf LLONG_MAX #define iinf INT_MAX const char al='\n'; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); #ifndef ONLINE_JUDGE freopen("test.in","r",stdin); #endif int n,i; cin>>n; vector<int>a(n+5); vector<bool>jyl(n+5); fz1(i,n-1) cin>>a[i]; cout<<a[1]<<al; jyl[a[1]]=1; int index=n; fz1(i,n-1) { while(jyl[index]) index--; if(jyl[a[i+1]]||i==n-1) { cout<<a[i]<<" "<<index<<al; jyl[index]=1; } else { cout<<a[i]<<" "<<a[i+1]<<al; jyl[a[i+1]]=1; } } return 0; }
标签:--,题解,cin,long,codeforces1283F,itr,define From: https://www.cnblogs.com/gaojunonly1/p/17551485.html