This commit is contained in:
Zengtudor 2024-10-02 17:13:26 +08:00
parent b7c267cb3c
commit 74f4918910
3 changed files with 32 additions and 9 deletions

View File

@ -27,3 +27,5 @@ add_executable(P7076 ${CMAKE_CURRENT_LIST_DIR}/P7076/P7076.cpp)
add_executable(P7075 ${CMAKE_CURRENT_LIST_DIR}/P7075/P7075.cpp) add_executable(P7075 ${CMAKE_CURRENT_LIST_DIR}/P7075/P7075.cpp)
add_executable(P1003 ${CMAKE_CURRENT_LIST_DIR}/P1003/P1003.cpp) add_executable(P1003 ${CMAKE_CURRENT_LIST_DIR}/P1003/P1003.cpp)
add_executable(P1311 ${CMAKE_CURRENT_LIST_DIR}/P1311/P1311.cpp)

View File

@ -13,7 +13,6 @@ const int MAX_N = 1e4+5;
int n; int n;
Point dir; Point dir;
Point arr[MAX_N][2]; Point arr[MAX_N][2];
int ans;
int main(){ int main(){
std::iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr); std::iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
@ -26,13 +25,11 @@ int main(){
} }
cin>>dir.x>>dir.y; cin>>dir.x>>dir.y;
for(const int i:range(0,n)){ for(int i=n-1;i>=0;i--){
if(arr[i][0].x<=dir.x && dir.x <= arr[i][1].x if(arr[i][0].x<=dir.x && dir.x <= arr[i][0].x+arr[i][1].x
&& arr[i][0].y<=dir.y && dir.y <= arr[i][1].y){ && arr[i][0].y<=dir.y && dir.y <= arr[i][0].y+arr[i][1].y){
ans++; std::cout<<i+1<<"\n";
return 0;
} }
} }
std::cout<<(ans==0?-1:ans)<<"\n";
} }

24
P1311/P1311.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <cstddef>
#include <iostream>
#include <ranges>
using std::iostream,std::cin,std::cout;
constexpr const auto range = std::ranges::views::iota;
const int MAX_N {(size_t)2e5+5},MAX_COLOR {50+5};
int n,k,p;
int ans;
struct Hotel{
int color,min_cost;
}hotel[MAX_N];
int main(){
iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
cin>>n>>k>>p;
for(const int i:range(1,n+1)){
cin>>hotel[i].color>>hotel[i].min_cost;
}
}