結果
問題 | No.1864 Shortest Paths Counting |
ユーザー | kmjp |
提出日時 | 2022-03-04 23:22:19 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 103 ms / 2,000 ms |
コード長 | 1,873 bytes |
コンパイル時間 | 2,474 ms |
コンパイル使用メモリ | 214,284 KB |
実行使用メモリ | 13,388 KB |
最終ジャッジ日時 | 2024-07-18 21:56:45 |
合計ジャッジ時間 | 5,274 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
7,552 KB |
testcase_01 | AC | 5 ms
7,424 KB |
testcase_02 | AC | 5 ms
7,424 KB |
testcase_03 | AC | 5 ms
7,424 KB |
testcase_04 | AC | 5 ms
7,552 KB |
testcase_05 | AC | 4 ms
7,552 KB |
testcase_06 | AC | 5 ms
7,424 KB |
testcase_07 | AC | 5 ms
7,424 KB |
testcase_08 | AC | 5 ms
7,424 KB |
testcase_09 | AC | 62 ms
11,008 KB |
testcase_10 | AC | 66 ms
10,752 KB |
testcase_11 | AC | 67 ms
10,624 KB |
testcase_12 | AC | 79 ms
11,772 KB |
testcase_13 | AC | 64 ms
10,752 KB |
testcase_14 | AC | 66 ms
10,880 KB |
testcase_15 | AC | 70 ms
11,136 KB |
testcase_16 | AC | 63 ms
10,752 KB |
testcase_17 | AC | 68 ms
11,264 KB |
testcase_18 | AC | 69 ms
11,136 KB |
testcase_19 | AC | 63 ms
11,008 KB |
testcase_20 | AC | 72 ms
11,264 KB |
testcase_21 | AC | 62 ms
10,624 KB |
testcase_22 | AC | 70 ms
10,880 KB |
testcase_23 | AC | 63 ms
11,008 KB |
testcase_24 | AC | 4 ms
7,552 KB |
testcase_25 | AC | 103 ms
13,388 KB |
testcase_26 | AC | 38 ms
10,624 KB |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54, from main.cpp:1: In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]', inlined from 'void solve()' at main.cpp:69:8: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'ret' may be used uninitialized [-Wmaybe-uninitialized] 202 | { return _M_insert(__n); } | ~~~~~~~~~^~~~~ main.cpp: In function 'void solve()': main.cpp:63:12: note: 'ret' was declared here 63 | ll ret; | ^~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;} template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int N; ll X[202020],Y[202020]; ll mo=998244353; template<class V, int ME> class BIT_mod { public: V bit[1<<ME]; BIT_mod(){ZERO(bit);}; V operator()(int e) { if(e<0) return 0; ll s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s%mo;} void add(int e,V v) { e++; while(e<=1<<ME) { bit[e-1]+=v; bit[e-1] -= (bit[e-1]>=mo)?mo:0; e+=e&-e;}} }; BIT_mod<int,20> bt; void solve() { int i,j,k,l,r,x,y; string s; cin>>N; FOR(i,N) { cin>>x>>y; X[i]=x+y; Y[i]=x-y; } for(i=N-1;i>=0;i--) { X[i]-=X[0]; Y[i]-=Y[0]; } if(X[N-1]<0) { FOR(i,N) X[i]=-X[i]; } if(Y[N-1]<0) { FOR(i,N) Y[i]=-Y[i]; } vector<ll> Ys; vector<pair<ll,int>> P; FOR(i,N) { if(X[i]<X[0]||X[i]>X[N-1]) continue; if(Y[i]<Y[0]||Y[i]>Y[N-1]) continue; Ys.push_back(Y[i]); } sort(ALL(Ys)); FOR(i,N) { if(i==0) continue; if(X[i]<X[0]||X[i]>X[N-1]) continue; if(Y[i]<Y[0]||Y[i]>Y[N-1]) continue; Y[i]=lower_bound(ALL(Ys),Y[i])-Ys.begin(); P.push_back({X[i],Y[i]}); } sort(ALL(P)); ll ret; bt.add(0,1); FORR2(x,y,P) { ret=bt(y); bt.add(y,ret); } cout<<ret<<endl; } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }