結果
| 問題 | No.694 square1001 and Permutation 3 |
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2018-06-08 23:33:26 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,013 bytes |
| 記録 | |
| コンパイル時間 | 870 ms |
| コンパイル使用メモリ | 114,660 KB |
| 実行使用メモリ | 71,784 KB |
| 最終ジャッジ日時 | 2026-03-20 10:07:28 |
| 合計ジャッジ時間 | 11,649 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 12 TLE * 1 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:38:17: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
38 | ans += n-i-1;
| ~~~~^~~~~~~~
main.cpp:33:8: note: 'ans' was declared here
33 | ll ans;
| ^~~
ソースコード
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(ll i=n;i<N;i++)
#define RREP(i,n,N) for(ll i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf=1e9+7;
ll n;
ll A[500010];
map<ll, ll> m;
set<ll> s;
ll cnt[500010]; //右に大きいものが何個
int main(){
cin>>n;
ll ans;
REP(i,0,n){
cin>>A[i];
if(A[i]==n){
s.insert(i);
ans += n-i-1;
}
m[A[i]]=i;
}
RREP(i,1,n){
ll tmp = distance(s.lower_bound(m[i]), s.end());
s.insert(m[i]);
//p(tmp);
ans += n - (m[i]+1) - tmp;
}
p(ans);
REP(i,0,n-1){
ans += n - A[i] - (A[i]-1);
p(ans);
}
return 0;
}
dnish