結果
| 問題 |
No.1147 土偶Ⅱ
|
| ユーザー |
beet
|
| 提出日時 | 2020-08-07 15:45:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 500 ms |
| コード長 | 1,663 bytes |
| コンパイル時間 | 3,052 ms |
| コンパイル使用メモリ | 199,560 KB |
| 最終ジャッジ日時 | 2025-01-12 15:45:39 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#define PROBLEM "https://yukicoder.me/problems/4918"
#include<bits/stdc++.h>
using namespace std;
#define call_from_test
#ifndef call_from_test
#include <bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename TV, const int N> void read_tuple_impl(TV&) {}
template<typename TV, const int N, typename Head, typename... Tail>
void read_tuple_impl(TV& ts) {
get<N>(ts).emplace_back(*(istream_iterator<Head>(cin)));
read_tuple_impl<TV, N+1, Tail...>(ts);
}
template<typename... Ts> decltype(auto) read_tuple(size_t n) {
tuple<vector<Ts>...> ts;
for(size_t i=0;i<n;i++) read_tuple_impl<decltype(ts), 0, Ts...>(ts);
return ts;
}
//END CUT HERE
#ifndef call_from_test
signed main(){
return 0;
}
#endif
#ifndef call_from_test
#include <bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//END CUT HERE
#ifndef call_from_test
signed main(){
return 0;
}
#endif
#undef call_from_test
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
int n,m;
cin>>n>>m;
auto [as, bs]=read_tuple<int, int>(m);
vector G(n,vector(n,n));
for(int i=0;i<n;i++) G[i][i]=0;
for(int i=0;i<m;i++){
as[i]--;bs[i]--;
G[as[i]][bs[i]]=1;
G[bs[i]][as[i]]=1;
}
for(int k=0;k<n;k++)
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
chmin(G[i][j],G[i][k]+G[k][j]);
int ans=0;
for(int i=0;i<n;i++)
for(int j=0;j<i;j++)
for(int k=0;k<j;k++)
if(G[i][j]!=2 and G[i][k]!=2 and G[j][k]!=2) ans++;
cout<<ans<<endl;
return 0;
}
beet