結果
問題 |
No.1340 おーじ君をさがせ
|
ユーザー |
![]() |
提出日時 | 2021-01-15 22:06:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,428 bytes |
コンパイル時間 | 1,998 ms |
コンパイル使用メモリ | 185,480 KB |
実行使用メモリ | 136,960 KB |
最終ジャッジ日時 | 2024-11-26 19:41:53 |
合計ジャッジ時間 | 41,216 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 47 WA * 2 TLE * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> P; typedef vector<ll> VI; typedef vector<VI> VVI; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() constexpr ll MOD=1000000007; constexpr ll INF=1e18; VVI edge(110,VI(0)); int main(){ int n, m; cin >> n >> m; ll t; cin >> t; int a, b; bool f[110][110]={0}; REP(i,m){ cin >> a >> b; f[a][b]=1; } REP(i,n)REP(j,n){ if(f[i][j]) edge[i].push_back(j); } queue<P> q; q.push({0,0}); map<P,bool> mp; mp[{0,0}]=1; while(!q.empty()){ P p=q.front(); if(p.second>=11000) break; q.pop(); for(auto to:edge[p.first]){ if(!mp[{to,p.second+1}]){ mp[{to,p.second+1}]=1; q.push({to,p.second+1}); } } } if(t<11000){ int ans=0; REP(i,n) ans+=mp[{i,t}]; cout << ans << endl; } else{ int ans=0; REP(i,n){ int x=-1; for(int j=10000;j<10200;j++){ if(mp[{i,j}]){ if(x!=-1){ if(t%(j-x)==x%(j-x)) ans++; break; } x=j; } } } cout << ans << endl; } return 0; }