#include <iostream>
using namespace std;
#define MAXN 100000
int n;
int boundary[MAXN+1];
int NumOfConnection[MAXN+1];
void printValue(int n)
{
int v1=n*(n+1)/2;
int v2=(n*(n+1)*(2*n+1)/6 + v1) / 2;
cout << v1 << " " << v2 << endl;
}
int main()
{
cin >> n;
for(int i=1;i<=n;i++)
{
boundary[i]=i;
NumOfConnection[i]=1;
}
for(int i=0;i<n-1;i++)
{
int t;
cin >> t;
int left=boundary[t];
int right=boundary[t+1];
int sum=NumOfConnection[t]+NumOfConnection[t+1];
printValue(sum-1);
NumOfConnection[left]=NumOfConnection[right]=sum;
int tmp=boundary[left];
boundary[left]=boundary[t+1];
boundary[right]=(left==t) ? tmp : boundary[t];
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
188 ms |
2452 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |