結果

問題 No.1935 Water Simulation
ユーザー zezerozezero
提出日時 2022-05-13 22:36:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,061 bytes
コンパイル時間 3,270 ms
コンパイル使用メモリ 166,356 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 08:07:27
合計ジャッジ時間 4,610 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
  int a,b = 0,c = 0,d = 0,v1,v2,v3,v4;
  ll n;
  cin >> v1 >> v2 >> v3 >> v4 >> n;
  map<ll,ll> mp;
  vector<ll> val;
  a = v1;
  ll count = 0;
  mp[1000000000LL*a + 1000000LL*b + 1000LL*c + d] = count;
  count++;
  val.push_back(1000000000LL*a + 1000000LL*b + 1000LL*c + d);
  ll offset = 0;
  ll s = 0;
  ll loopsize = 0;
  int trun = 0;
  a = v1;
  while(1){
    if (trun == 0){
      int diff = v2-b;
      b += min(a,v2-b);
      a -= min(a,diff); 
    }
    else if (trun == 1){
      int diff = v3-c;
      c += min(b,diff);
      b -= min(b,diff);
    }
    else if (trun == 2){
      int diff = v4-d;
      d += min(c,diff);
      c -= min(c,diff);
    }
    else{
      int diff = v1-a;
      a += min(d,diff);
      d -= min(d,diff);
    }
    ll hash = 1000000000LL*a + 1000000LL*b + 1000LL*c + d;
    if (mp.count(hash)){
      loopsize = count-mp[hash];
      offset = mp[hash];
      s = hash;
      break;
    }
    mp[hash] = count;
    val.push_back(hash);
    count++;
    trun++;
    trun%=4; 
  }
  //for (auto y:val){
  //  cout << y << " ";
  //}
  //cout << endl;
  if (n <= offset){
      vector<ll> ans(4);
      ll z = val[n];
      for (int i = 0; i < 4;i++){
        ans[3-i] = z%1000;
        z/=1000;     
      }
      for (int i = 0; i < 4;i++){
        if (i == 0) cout << ans[i];
        else cout << " " << ans[i];
      }
      cout << endl;
  }
  else{
    n -= offset;
    n%=loopsize;
    vector<ll> ans(4);
      ll z = val[n+offset];
      for (int i = 0; i < 4;i++){
        ans[3-i] = z%1000;
        z/=1000;     
      }
      for (int i = 0; i < 4;i++){
        if (i == 0) cout << ans[i];
        else cout << " " << ans[i];
      }
      cout << endl;
    
  }
  
  return 0;
}
0