結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー 0w10w1
提出日時 2017-01-03 17:02:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,751 bytes
コンパイル時間 2,488 ms
コンパイル使用メモリ 199,156 KB
実行使用メモリ 36,160 KB
最終ジャッジ日時 2023-10-23 16:05:56
合計ジャッジ時間 17,335 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 729 ms
36,160 KB
testcase_38 AC 545 ms
25,144 KB
testcase_39 AC 396 ms
25,144 KB
testcase_40 AC 413 ms
25,144 KB
testcase_41 AC 508 ms
25,148 KB
testcase_42 AC 503 ms
25,148 KB
testcase_43 AC 185 ms
14,696 KB
testcase_44 AC 148 ms
15,196 KB
testcase_45 AC 265 ms
36,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef pair< int, int > pii;
typedef vector< pii > vp;
typedef vector< double > vd;
typedef vector< vd > vvd;
typedef vector< string > vs;

template< class T1, class T2 >
int upmin( T1 &x, T2 v ){
  if( x > v ){
    x = v;
    return 1;
  }
  return 0;
}

template< class T1, class T2 >
int upmax( T1 &x, T2 v ){
  if( x < v ){
    x = v;
    return 1;
  }
  return 0;
}

const int INF = 0x3f3f3f3f;

int N;
vi L;
int T;
vs name, P;

void init(){
  cin >> N;
  L = vi( N );
  for( int i = 0; i < N; ++i ){
    cin >> L[ i ];
  }
  cin >> T;
  name = P = vs( T );
  for( int i = 0; i < T; ++i ){
    cin >> name[ i ] >> P[ i ];
  }
}

map< int, int > mp;

struct fenwick{
  vi dat;
  fenwick( int sz ){
    dat = vi( sz );
  }
  void update( int x, int v ){
    for( int i = x; i < dat.size(); i += i & -i ){
      dat[ i ] += v;
    }
  }
  int sum( int x ){
    int res = 0;
    for( int i = x; i > 0; i -= i & -i ){
      res += dat[ i ];
    }
    return res;
  }
} *ftree;

void preprocess(){
  vi prob_solved_cnt( N );
  map< string, int > user2score;
  vi score = { 0 };
  for( int i = 0; i < T; ++i ){
    if( P[ i ] == "?" ) continue;
    int p = P[ i ][ 0 ] - 'A';
    int v = user2score[ name[ i ] ];
    v += 50 * L[ p ] + 500 * L[ p ] / ( 8 + 2 * ++prob_solved_cnt[ p ] );
    user2score[ name[ i ] ] = v;
    score.emplace_back( v );
  }
  sort( score.begin(), score.end() );
  score.erase( unique( score.begin(), score.end() ), score.end() );
  for( int i = 0; i < score.size(); ++i ){
    mp[ score[ i ] ] = i + 1;
  }
  ftree = new fenwick( score.size() + 1 );
}

void solve(){
  vi prob_solved_cnt( N );
  map< string, int > user2score;
  map< string, int > user2rank_in_samescore;
  for( int i = 0; i < T; ++i ){
    if( user2score.count( name[ i ] ) ) continue;
    ftree->update( mp[ 0 ], 1 );
    user2score[ name[ i ] ] = 0;
    user2rank_in_samescore[ name[ i ] ] = 0;
  }
  for( int i = 0; i < T; ++i ){
    if( P[ i ] == "?" ){
      cout << ftree->sum( ftree->dat.size() - 1 ) - ftree->sum( mp[ user2score[ name[ i ] ] ] ) + user2rank_in_samescore[ name[ i ] ] + 1 << endl;
    } else{
      int p = P[ i ][ 0 ] - 'A';
      int v = user2score[ name[ i ] ];
      ftree->update( mp[ v ], -1 );
      v += 50 * L[ p ] + 500 * L[ p ] / ( 8 + 2 * ++prob_solved_cnt[ p ] );
      user2rank_in_samescore[ name[ i ] ] = ftree->sum( mp[ v ] ) - ftree->sum( mp[ v ] - 1 ); // 0 idx
      ftree->update( mp[ v ], 1 );
      user2score[ name[ i ] ] = v;
    }
  }
}

signed main(){
  ios::sync_with_stdio( 0 );
  init();
  preprocess();
  solve();
  return 0;
}
0