답안 #499574

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499574 2021-12-28T19:44:27 Z anurat123 경주 (Race) (IOI11_race) C++14
0 / 100
1 ms 284 KB
/*
           .--.                  Try not.
 ::\`--._,'.::.`._.--'/::     Do or do not.
 ::::.  ` __::__ '  .::::    There is no try.
 ::::::-:.`'..`'.:-::::::
 ::::::::\ `--' /::::::::              -Yoda
 
-->Take care regarding graph questions while taking input 1/0 indexed
-->Always use (ll)round() after doing fft to get correct result and make 
   sure it fits within ll
////////////////|!!!!ALERT!!!!|\\\\\\\\\
--!!!!!>DONT FORGET TO SWITCH OFF DB BEFORE SUBMISSION<!!!!----
-->TO handle overflow use difference in comparison
-->Subarray Max prop think kadanes
-->Try to avoid default string comparator
-->Questions are not complicated(except those [implementation])
-->Codes are short and simple
-->Thats the charm of CP
-->Do not overthink
-->Find an invariant
-->If you think there is any monotonicity==>binary search
-->Optimal substructure with low constraints==>dp
-->Grids==>Maybe Graph
-->very large contraints:Either simple math or log complexity
-->For greedy invariant identification is the most imp step
-->Enjoy while u code
-->Follow 20-20-20 rule(v.v imp)
-->Beware of Seg Fault in Seg Tree(2*n/4*n)
-->Dont Hip Hop between problems
-->For segfault first check if you have alloted enough memory
-->Use fast pow even when base is 2 and not '<<' operator to prevent overflow
-->Have fun,this is after all a mind sport
                                  */

#include<bits/stdc++.h>
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define umplc unordered_map<char,ll>
#define hf 31
#define f first
#define s second
#define pb push_back
#define pp pop_back
//#define file_ipop
#define MOD
#define M 1000000007
#define fr(i,str,n) for(ll i=str;i<n;++i)
#define nl cout<<endl
//#define DB
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pi; 
typedef vector<pair<int,int>> vpi;

#ifdef DB
#define debug(x) cerr << #x << '=' << (x) << endl;
#define debugBIT(bit)                               \
    {                                               \
        cerr << "BIT: ";                            \
        for (int i = 0; i < bit.size() - 1; i++)    \
        {                                           \
            if (i == 0)                             \
                cerr << qry(i) << " ";              \
            else                                    \
                cerr << qry(i) - qry(i - 1) << " "; \
        }                                           \
        cerr << endl;                               \
    }

#else
#define debug(x) 
#define debugBIT(bit)
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef uniform_int_distribution<ll> uni_dist;
ll abss(ll a)
{
    if(a<0)	return -a;
    return a;
}
ll ones(ll a)
{
  ll cnt = 0;
  while(a>0)
  {
    if(a&1) cnt++;
    a>>=1;
  }
  return cnt;
}
#ifdef MOD
ll fast_pow(ll b, ll e,ll width=M)
{
  if(e==0)
  {
    return 1;
  }
  else if(e==1)
  {
    return b%width;
  }
  b = b%width;
  ll ans = 1;
  while(e>0)
  {
    if((e&1)==1)
    {
      ans = (ans*b)%width;
    }
    e>>=1;
    b = (b*b)%width;
  }
  return ans;
}
ll mod_inv(ll a,ll width=M)
{
  return fast_pow(a,width-2,width);
}
template<typename Number,Number width>
class ModularArithmetic
{
  private :
    Number n;
  public:
    friend ostream& operator<<(ostream& os, ModularArithmetic const & num) {
        return os << num.n;
      }
    friend istream& operator>>(istream &is,ModularArithmetic  & num)
    {
      is>>num.n;return is;
    }
    ModularArithmetic() : n(0){}
    ModularArithmetic(Number n) : n(n % width){if(this->n<0)this->n+=width;}
    Number get() const {return n;}
    ModularArithmetic operator+(const ModularArithmetic &b){Number t = (n+b.get())%width;if(t<0)return ModularArithmetic(width+t);return ModularArithmetic(t);}
    ModularArithmetic operator-(const ModularArithmetic &b){Number t = (n-b.get())%width;if(t<0)return ModularArithmetic(width+t);return ModularArithmetic(t);}
    ModularArithmetic operator*(const ModularArithmetic &b){Number t = (n*b.get())%width;if(t<0)return ModularArithmetic(width+t);return ModularArithmetic(t);}
    ModularArithmetic operator/(const ModularArithmetic &b)
    {
        assert(b.get()!=0);
        Number ans = n*mod_inv(b.get(),width);
        if((ans)<0)return ModularArithmetic(width+(ans)%width);return ModularArithmetic(ans%width);
    }
    ModularArithmetic &operator+=(const ModularArithmetic &b){n = (n+b.get())%width;if(n<0)n=n+width;return *this;}
    ModularArithmetic &operator-=(const ModularArithmetic &b){n = (n-b.get())%width;if(n<0)n=n+width;return *this;}
    ModularArithmetic &operator*=(const ModularArithmetic &b){n = (n*b.get())%width;if(n<0)n=n+width;return *this;}
    ModularArithmetic &operator/=(const ModularArithmetic &b)
    {
      assert(b.get()!=0);
        n = (n*mod_inv(b.get(),width))%width;if(n<0)n=n+width;return *this;
    }
};
typedef ModularArithmetic<ll,M> lm;
typedef vector<lm> vlm;
#endif


template<class T,size_t N>ostream &operator<<(ostream &os,const array<T,N> &p){os<<"<";for(auto&it:p)os<<it<<" ";return os<<">";}
template<class S,class T>ostream &operator<<(ostream &os,const pair<S,T> &p){return os<<"("<<p.f<<","<<p.s<<")";}
template<class S,class T>istream &operator>>(istream &is,pair<S,T> &p){return is>>p.f>>p.s;}
template<class T>ostream &operator<<(ostream &os,const vector<T> &p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T,typename Cmp>ostream &operator<<(ostream &os,const set<T,Cmp>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class T>ostream &operator<<(ostream &os,const multiset<T>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T,typename Cmp>ostream &operator<<(ostream &os,const map<S,T,Cmp>&p){os<<"[";for(auto&it:p)os<<it<<" ";return os<<"]";}
template<class S,class T>istream &operator>>(istream &is,const pair<S,T> &p){return is>>p.f>>p.s;}
template<class T> istream &operator>>(istream &is, vector<T> &p){for(auto&itr:p)is>>itr;return is;}
template<class T>void dbs(string str,T t){cerr<<str<<":"<<t<<"\n";}
template<class T,class...S>void dbs(string str,T t,S... s){ll idx=str.find(',');cerr<<str.substr(0,idx)<<":"<<t<<",";dbs(str.substr(idx+1),s...);}
#ifdef DB
#define debarr(a,n)cerr<<#a<<":";for(ll i=0;i<n;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(ll i=0;i<row;i++){for(ll j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...)dbs(#__VA_ARGS__,__VA_ARGS__)
#else
#define pr(...){}
#define debarr(a,n){}
#define debmat(mat,row,col){}
#endif
template<class T>
void print(T t)  {
    cout<<t<<"\n";    
}
template<class T,class...S>
void print(T t,S... ss)  {
    cout<<t<<" ";
    print(ss...);
}


int best_path(int n,int k,int H[][2],int L[]){
    return -1;
}


/*
void solve()
{
    //Write code here
    
    
}

int main()
{
    freopen("err.txt","w",stderr);
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef file_ipop
    freopen("filename.in","r",stdin);
    freopen("filename.out","w",stdout);
#endif
    ll t;cin>>t;while(t--)
    solve();
    return 0;
}
*/

Compilation message

race.cpp: In member function 'ModularArithmetic<Number, width> ModularArithmetic<Number, width>::operator/(const ModularArithmetic<Number, width>&)':
race.cpp:148:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  148 |         if((ans)<0)return ModularArithmetic(width+(ans)%width);return ModularArithmetic(ans%width);
      |         ^~
race.cpp:148:64: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  148 |         if((ans)<0)return ModularArithmetic(width+(ans)%width);return ModularArithmetic(ans%width);
      |                                                                ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 284 KB Output isn't correct
2 Halted 0 ms 0 KB -