Submission #13534282
Source Code Expand
/*input
10
3 2
3 2
-1 1
2 -1
-3 -9
-8 12
7 7
8 1
8 2
8 4
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define rep(i,n) \
for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
for(int i = a; i < b; i++)
#define all(c) \
c.begin(), c.end()
#define init(arr, num) \
memset(arr, num, sizeof(arr))
#define fast\
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
freopen("input.txt", "r", stdin);
#define outputFile \
freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#ifdef Voneone
#define TRACE
#endif
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cout.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
#else
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
ii reduce(int x, int y){
if(x == 0) return {0,1};
if(y == 0) return {1,0};
int g = __gcd(abs(x), abs(y));
if(y > 0)
return {x/g, y/g};
else
return {-x/g, -y/g};
}
ii inverse(ii p){
return reduce(-p.second, p.first);
}
int modpower(int x, unsigned int y, int p)
{
int res = 1; // Initialize result
x = x % p; // Update x if it is more than or
// equal to p
while (y > 0)
{
// If y is odd, multiply x with result
if (y & 1)
res = (res*x) % p;
// y must be even now
y = y>>1; // y = y/2
x = (x*x) % p;
}
return res;
}
void solve()
{
int n;
cin >> n;
int inv = 0;
map<ii, int> freq;
rep(i, n){
int a , b;
cin >> a >> b;
if(a == 0 && b == 0){
inv++;
inv %= modM;
}
else{
// auto inv = reduce(a,b);
// trace(a, b, inv.first, inv.second);
freq[reduce(a,b)]++;
}
}
int ans = 1;
set<ii> vis;
for(auto x : freq){
auto y = inverse(x.first);
if(vis.count(x.first) || vis.count(y))
continue;
auto pos = freq.find(y);
if(pos == freq.end()){
ans *= modpower(2, x.second, modM);
ans %= modM;
vis.insert(x.first);
trace(x.first.first, x.first.second, x.second);
}else{
int tmp = (modpower(2, x.second, modM) + modpower(2, pos->second, modM) - 1)%modM;
ans *= tmp;
ans %= modM;
vis.insert(x.first);
vis.insert(pos->first);
trace(x.first.first, x.first.second, x.second, pos->first.first, pos->first.second, pos->second);
}
}
if(inv){
ans *= (inv+1)%modM;
ans %= modM;
// cout << ans;
// return;
}
cout << ans-1;
}
signed main()
{
#ifdef _DEBUG
inputFile;
#endif
#ifndef __CINP
fast;
#endif
int T = 1;
// cin >> T;
while(T--){
solve();
cout << endl;
}
return 0;
}
Submission Info
| Submission Time |
|
| Task |
E - ∙ (Bullet) |
| User |
Voneone |
| Language |
C++ (GCC 9.2.1) |
| Score |
0 |
| Code Size |
3677 Byte |
| Status |
WA |
| Exec Time |
656 ms |
| Memory |
28576 KiB |
Judge Result
| Set Name |
Sample |
Subtask1 |
| Score / Max Score |
0 / 0 |
0 / 500 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample_01.txt, sample_02.txt |
| Subtask1 |
sample_01.txt, sample_02.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt |
| Case Name |
Status |
Exec Time |
Memory |
| sample_01.txt |
AC |
2 ms |
3512 KiB |
| sample_02.txt |
AC |
2 ms |
3500 KiB |
| sub1_01.txt |
AC |
656 ms |
28576 KiB |
| sub1_02.txt |
AC |
2 ms |
3564 KiB |
| sub1_03.txt |
AC |
2 ms |
3604 KiB |
| sub1_04.txt |
AC |
2 ms |
3508 KiB |
| sub1_05.txt |
AC |
2 ms |
3508 KiB |
| sub1_06.txt |
AC |
2 ms |
3640 KiB |
| sub1_07.txt |
AC |
2 ms |
3452 KiB |
| sub1_08.txt |
AC |
3 ms |
3564 KiB |
| sub1_09.txt |
AC |
2 ms |
3448 KiB |
| sub1_10.txt |
AC |
2 ms |
3500 KiB |
| sub1_11.txt |
WA |
48 ms |
4324 KiB |
| sub1_12.txt |
WA |
95 ms |
5004 KiB |
| sub1_13.txt |
WA |
138 ms |
5652 KiB |
| sub1_14.txt |
WA |
77 ms |
3744 KiB |
| sub1_15.txt |
WA |
24 ms |
3580 KiB |
| sub1_16.txt |
WA |
83 ms |
4980 KiB |
| sub1_17.txt |
WA |
53 ms |
3624 KiB |
| sub1_18.txt |
WA |
66 ms |
3552 KiB |
| sub1_19.txt |
AC |
43 ms |
7580 KiB |
| sub1_20.txt |
AC |
180 ms |
15500 KiB |
| sub1_21.txt |
AC |
24 ms |
3576 KiB |