提出 #17982471
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
bool ok(vector<int> &a,vector<int> &b,int x){
int i1=lower_bound(all(a),x)-a.begin();
int i2=lower_bound(all(b),x)-b.begin();
if(a.empty())return false;
if(i1<0 || i1>=a.size())return false;
int c=a[i1];
if(c<x)return false;
if(b.empty() || i2<0 || i2>=b.size() || b[i2]<x)return true;
return c<b[i2];
}
bool check(vector<int> &a,vector<int> &b,int x){
int i1=upper_bound(all(a),x)-a.begin();
int i2=upper_bound(all(b),x)-b.begin();
--i1;--i2;
if(a.empty())return false;
if(i1<0 || i1>=a.size())return false;
if(a[i1]>x)return false;
if(b.empty() || i2<0 || i2>=b.size() || b[i2]>x)return true;
return a[i1]>b[i2];
}
void solve()
{
int h,w,n,m;
cin>>h>>w>>n>>m;
vector<vector<int>> bx(h+5),by(w+5),cx(h+5),cy(w+5);
for(int i=0;i<n;i++){
int r,c;
cin>>r>>c;
bx[r].emplace_back(c);
by[c].emplace_back(r);
}
for(int i=0;i<m;i++){
int r,c;
cin>>r>>c;
cx[r].emplace_back(c);
cy[c].emplace_back(r);
}
for(int i=0;i<=h;i++){
sort(all(bx[i]));
sort(all(cx[i]));
}
for(int i=0;i<=w;i++){
sort(all(by[i]));
sort(all(cy[i]));
}
//b-box
//c-cross
int ans=0;
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
if(ok(by[j],cy[j],i)){
++ans;
continue;
}
if(ok(bx[i],cx[i],j)){
++ans;
continue;
}
if(check(by[j],cy[j],i)){
++ans;
continue;
}
if(check(bx[i],cx[i],j)){
++ans;
continue;
}
// cerr<<i<<" "<<j<<"\n";
}
}
cout<<ans<<"\n";
}
int32_t main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while (t--)
{
solve();
}
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
E - Akari |
| ユーザ |
dharmaraj_82 |
| 言語 |
C++ (GCC 9.2.1) |
| 得点 |
500 |
| コード長 |
2512 Byte |
| 結果 |
AC |
| 実行時間 |
322 ms |
| メモリ |
11328 KiB |
コンパイルエラー
./Main.cpp: In function ‘bool ok(std::vector<int>&, std::vector<int>&, int)’:
./Main.cpp:17:18: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
17 | if(i1<0 || i1>=a.size())return false;
| ~~^~~~~~~~~~
./Main.cpp:20:31: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
20 | if(b.empty() || i2<0 || i2>=b.size() || b[i2]<x)return true;
| ~~^~~~~~~~~~
./Main.cpp: In function ‘bool check(std::vector<int>&, std::vector<int>&, int)’:
./Main.cpp:29:18: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
29 | if(i1<0 || i1>=a.size())return false;
| ~~^~~~~~~~~~
./Main.cpp:31:31: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
31 | if(b.empty() || i2<0 || i2>=b.size() || b[i2]>x)return true;
| ~~^~~~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
500 / 500 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
| All |
handmade_00.txt, max_random_00.txt, max_random_01.txt, max_random_02.txt, max_random_03.txt, max_random_04.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, sample_01.txt, sample_02.txt, sample_03.txt, surrounded_00.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| handmade_00.txt |
AC |
15 ms |
3656 KiB |
| max_random_00.txt |
AC |
193 ms |
10068 KiB |
| max_random_01.txt |
AC |
188 ms |
9912 KiB |
| max_random_02.txt |
AC |
188 ms |
10004 KiB |
| max_random_03.txt |
AC |
191 ms |
10100 KiB |
| max_random_04.txt |
AC |
187 ms |
9888 KiB |
| random_00.txt |
AC |
322 ms |
11296 KiB |
| random_01.txt |
AC |
316 ms |
11328 KiB |
| random_02.txt |
AC |
3 ms |
3740 KiB |
| random_03.txt |
AC |
3 ms |
3580 KiB |
| random_04.txt |
AC |
160 ms |
9244 KiB |
| random_05.txt |
AC |
209 ms |
6552 KiB |
| random_06.txt |
AC |
168 ms |
6948 KiB |
| random_07.txt |
AC |
227 ms |
9824 KiB |
| random_08.txt |
AC |
45 ms |
4436 KiB |
| random_09.txt |
AC |
167 ms |
10492 KiB |
| sample_01.txt |
AC |
2 ms |
3652 KiB |
| sample_02.txt |
AC |
2 ms |
3616 KiB |
| sample_03.txt |
AC |
2 ms |
3500 KiB |
| surrounded_00.txt |
AC |
196 ms |
10220 KiB |