結果
| 問題 |
No.694 square1001 and Permutation 3
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2018-06-08 23:35:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 963 bytes |
| コンパイル時間 | 941 ms |
| コンパイル使用メモリ | 94,452 KB |
| 実行使用メモリ | 45,184 KB |
| 最終ジャッジ日時 | 2024-06-30 11:11:21 |
| 合計ジャッジ時間 | 7,269 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | WA * 8 TLE * 1 -- * 4 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39,
from main.cpp:6:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
inlined from 'int main()' at main.cpp:47:5:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
202 | { return _M_insert(__n); }
| ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:32:8: note: 'ans' was declared here
32 | 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;
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