# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
3357 |
2013-08-30T15:48:57 Z |
jiyong3 |
두 섬간의 연결 (kriii1_2) |
C++ |
|
220 ms |
2452 KB |
#include <iostream>
using namespace std;
#define MAXN 100000
int n;
int boundary[MAXN+1];
int NumOfConnection[MAXN+1];
void printValue(long long n)
{
long long v1=n*(n+1)/2;
long long 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);
int tmp=boundary[left];
boundary[left]=boundary[t+1];
boundary[right]=(left==t) ? tmp : boundary[t];
NumOfConnection[left]=NumOfConnection[right]=sum;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
220 ms |
2452 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |