結果
| 問題 | No.321 (P,Q)-サンタと街の子供たち |
| コンテスト | |
| ユーザー |
C
|
| 提出日時 | 2026-10-06 22:43:41 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 11 ms / 2,000 ms |
| + 795µs | |
| コード長 | 1,247 bytes |
| 記録 | |
| コンパイル時間 | 5,615 ms |
| コンパイル使用メモリ | 387,324 KB |
| 実行使用メモリ | 9,908 KB |
| 最終ジャッジ日時 | 2026-10-06 22:43:55 |
| 合計ジャッジ時間 | 10,379 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/polygon/point_data.hpp>
#include <boost/polygon/voronoi.hpp>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size()
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using pll=pair<ll,ll>;
// using mint=modint;
// using BoostPoint=boost::polygon::point_data<int>;
// using Voronoi=boost::polygon::voronoi_diagram<double>;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll P,Q,N;
cin>>P>>Q>>N;
if(P==0&&Q==0){
ll ans=0;
rep(i,0,N){
ll X,Y;
cin>>X>>Y;
if(X==0&&Y==0)ans++;
}
cout<<ans<<'\n';
return 0;
}
ll g=gcd(P,Q);
ll p=P/g,q=Q/g;
ll ans=0;
if(p%2!=q%2){
rep(i,0,N){
ll X,Y;
cin>>X>>Y;
if(X%g||Y%g)continue;
ans++;
}
}else{
rep(i,0,N){
ll X,Y;
cin>>X>>Y;
if(X%g||Y%g)continue;
if((X/g-Y/g)%2==0)ans++;
}
}
cout<<ans<<'\n';
}
C