結果
問題 |
No.461 三角形はいくつ?
|
ユーザー |
|
提出日時 | 2016-12-12 10:48:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,377 bytes |
コンパイル時間 | 792 ms |
コンパイル使用メモリ | 97,524 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-29 15:31:12 |
合計ジャッジ時間 | 16,535 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 13 WA * 28 |
ソースコード
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; typedef vector<int> VI; typedef vector<ll> VL; typedef pair<int, int> PI; const ll mod = 1e9 + 7; int main(void){ int n; cin >> n; vector<PI> pool[3]; REP(i, 0, 3) { pool[i].push_back(PI(0, 1)); } REP(i, 0, n) { int p, a, b; cin >> p >> a >> b; int g = __gcd(a, b); a /= g; b /= g; pool[p].push_back(PI(b, a + b)); } ll tot = (ll)(pool[0].size() * pool[1].size()) * pool[2].size(); set<PI> pool2(pool[2].begin(), pool[2].end()); REP(i, 0, pool[0].size()) { REP(j, 0, pool[1].size()) { PI u = pool[0][i]; PI v = pool[1][j]; PI w = PI(u.second * v.second - u.first * v.second - u.second * v.first, u.second * v.second); int g = __gcd(w.first, w.second); w.first /= g; w.second /= g; if (pool2.count(w)) { tot--; } } } cout << tot << endl; }