結果

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

テストケース

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

ソースコード

diff #

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

long long int Num(vector<long long int> v){
  long long int res = 0;
  for(int i=0;i<4;i++){
    res *= 101;
    res += v[i];
  }
  return res;
}

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<long long int> vec(1);
  vec[0] = Vol[0]*101*101*101;
  map<long long int,bool> Map;
  Map[vec[0]] = true;
  long long int same;
  bool ok = false;
  for(long long int i=1;;i++){
    long long int VNum = vec.back();
    vector<long long int> V(4);
    for(int j=0;j<4;j++){
      V[3-j] = VNum%101;
      VNum /= 101;
    }
    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;
    }
    long long int T = Num(V);
    if(Map[T]){
      same = T;
      break;
    }
    Map[T] = true;
    vec.push_back(T);
  }
  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;
    long long int A = vec[N];
    vector<long long int> ans(4);
    for(int i=0;i<4;i++){
      ans[3-i] = A%101;
      A /= 101;
    }
    cout << ans[0];
    for(int i=1;i<4;i++) cout << " " << ans[i];
    cout << endl;
  }
}
0