답안 #437263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
437263 2021-06-26T06:19:15 Z errorgorn 던전 (IOI21_dungeons) C++17
0 / 100
1546 ms 926272 KB
#include "dungeons.h"

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

#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back

#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
ll win_s[50005];
ll lose_s[50005];
ll win_n[50005];
ll lose_n[50005];

struct edge{
  int to;
  ll sum;
  ll mx; //we cant have more strength or we will overshoot
};

vector<ll> ds={0};
edge tkd[28][50005][28];

void init(int N, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) {
  n=N;

  rep(x,0,n) win_s[x]=s[x];
  rep(x,0,n) lose_s[x]=p[x];
  rep(x,0,n) win_n[x]=w[x];
  rep(x,0,n) lose_n[x]=l[x];

  for (int x=1;x<1e7;x<<=1) ds.pub(x); //start of bueket sizes
  ds.pub(1e18);

  //for (auto &it:ds) cout<<it<<" "; cout<<endl;

  memset(tkd,-1,sizeof(tkd));

  rep(i,0,sz(ds)-1){
    rep(x,0,n){
      if (win_s[x]<ds[i]){ //cfm will win
        tkd[i][x][0]=edge({win_n[x],win_s[x],(ll)1e18});
      }
      else if (win_s[x]<ds[i+1]){ //by default, we lose, but if we win we must stop!
        tkd[i][x][0]=edge({lose_n[x],lose_s[x],win_s[x]});
      }
      else{ //cfm will lose
        tkd[i][x][0]=edge({lose_n[x],lose_s[x],(ll)1e18});
      }
    }

    rep(y,0,29){
      rep(x,0,n){
        int temp=tkd[i][x][y].to;

        if (temp==-1 || tkd[i][temp][y].to==-1) continue;

        edge res=edge({
          tkd[i][temp][y].to,
          tkd[i][x][y].sum+tkd[i][temp][y].sum,
          min(tkd[i][x][y].mx,tkd[i][temp][y].mx-tkd[i][x][y].sum)
        });

        tkd[i][x][y+1]=res;
      }
    }
  }
}

long long simulate(int CURR, int S) {
  ll curr=CURR,s=S;

  rep(x,0,sz(ds)-1){
    //when we traverse a edge we cannot overshoot over some guy whos in our bucket
    //also sum must be contained in the bucket

    rep(y,30,0){
      if (tkd[x][curr][y].to!=-1 && s+tkd[x][curr][y].sum<ds[x+1] && s<tkd[x][curr][y].mx){
        tie(curr,s)=ii(tkd[x][curr][y].to,s+tkd[x][curr][y].sum);
      }
    }

    //cout<<"debug: "<<curr<<" "<<s<<endl;

    if (curr==n) break;

    //manually do extra one
    if (win_s[curr]<=s){
      s+=win_s[curr];
      curr=win_n[curr];
    }
    else{
      s+=lose_s[curr];
      curr=lose_n[curr];
    }
  }

  return s;

}

Compilation message

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:55:35: warning: narrowing conversion of 'win_n[x]' from 'long long int' to 'int' [-Wnarrowing]
   55 |         tkd[i][x][0]=edge({win_n[x],win_s[x],(ll)1e18});
      |                            ~~~~~~~^
dungeons.cpp:58:36: warning: narrowing conversion of 'lose_n[x]' from 'long long int' to 'int' [-Wnarrowing]
   58 |         tkd[i][x][0]=edge({lose_n[x],lose_s[x],win_s[x]});
      |                            ~~~~~~~~^
dungeons.cpp:61:36: warning: narrowing conversion of 'lose_n[x]' from 'long long int' to 'int' [-Wnarrowing]
   61 |         tkd[i][x][0]=edge({lose_n[x],lose_s[x],(ll)1e18});
      |                            ~~~~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 590 ms 920828 KB Output is correct
2 Correct 448 ms 920884 KB Output is correct
3 Incorrect 474 ms 921092 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 451 ms 921048 KB Output is correct
2 Runtime error 225 ms 17132 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 523 ms 921052 KB Output is correct
2 Incorrect 1546 ms 926272 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 523 ms 921052 KB Output is correct
2 Incorrect 1546 ms 926272 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 523 ms 921052 KB Output is correct
2 Incorrect 1546 ms 926272 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 451 ms 921048 KB Output is correct
2 Runtime error 225 ms 17132 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -