結果

問題 No.1935 Water Simulation
ユーザー AuroraAurora
提出日時 2022-05-13 21:55:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,397 bytes
コンパイル時間 1,871 ms
コンパイル使用メモリ 183,044 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 07:06:39
合計ジャッジ時間 3,182 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:55:18: 警告: ‘t’ may be used uninitialized [-Wmaybe-uninitialized]
   55 |     for(int i=0;i<t;i++) vec.pop_back();
      |                 ~^~
main.cpp:51:19: 備考: ‘t’ はここで定義されています
   51 |     long long int t;
      |                   ^

ソースコード

diff #

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

int main(){
  vector<long long int> Vol(4);
  long long int N;
  for(int i=0;i<4;i++) cin >> Vol[i];
  cin >> N;
  vector<vector<long long int>> vec(1,vector<long long int>(4));
  vec[0][0] = Vol[0];
  for(int i=1;i<4;i++) vec[0][i] = 0;
  map<vector<long long int>,bool> Map;
  Map[vec[0]] = true;
  vector<long long int> same;
  bool ok = false;
  for(long long int i=1;;i++){
    vector<long long int> V = vec.back();
    vector<long long int> NV(4);
    int t = (i-1)%4;
    int u = t+1;
    u %= 4;
    if(V[u]+V[t] <= Vol[u]){
      NV[u] = V[u]+V[t];
      NV[t] = 0;
    }
    else{
      NV[t] = V[t]-(Vol[u]-V[u]);
      NV[u] = Vol[u];
    }
    for(int j=0;j<4;j++){
      if(j != t && j != u){
        NV[j] = V[j];
      }
    }
    V = NV;
    if(i == N){
      cout << V[0];
      for(int j=1;j<4;j++) cout << " " << V[j];
      cout << endl;
      ok = true;
      break;
    }
    if(Map[V]){
      same = V;
      break;
    }
    Map[V] = true;
    vec.push_back(V);
  }
  if(!ok){
    long long int t;
    for(int i=0;i<vec.size();i++) if(vec[i] == same) t = i;
    N -= t;
    reverse(vec.begin(),vec.end());
    for(int i=0;i<t;i++) vec.pop_back();
    reverse(vec.begin(),vec.end());
    long long int S = vec.size();
    N %= S;
    cout << vec[N][0];
    for(int i=1;i<4;i++) cout << " " << vec[N][i];
    cout << endl;
  }
}
0