QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#849510 | #8468. Collinear Arrangements | liyujia | Compile Error | / | / | C++17 | 1.4kb | 2025-01-09 15:54:50 | 2025-01-09 15:54:51 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
using namespace std;
using namespace __gnu_pbds;
const int N = 500005;
int n, q, x[N], y[N], id[N], x1, y1, x2, y2;
gp_hash_table <int, int> mp;
int calc(int x, int y){
int ans = 1;
if(x < 0) x = -x, ans = -ans;
if(y < 0) y = -y, ans = -ans;
int g = __gcd(x, y); x /= g, y /= g;
return (x * (int)3e9 + y) * ans;
}
int crs(int id){ return (x1 - x[id]) * (y2 - y[id]) - (x2 - x[id]) * (y1 - y[id]);}
int slv(int l, int r, int cof){
int ans = 0, mid = l + r >> 1, p1 = crs(mid) * cof, p2 = crs(mid + 1) * cof;
if(r - l <= 4) for(int i = l; i <= r; i++) ans += !crs(i);
else if(p1 < p2 && p2 <= 0) ans = slv(mid + 1, r, cof);
else if(p1 > p2 && p1 <= 0) ans = slv(l, mid, cof);
else ans = slv(l, mid, cof) + slv(mid + 1, r, cof);
return ans;
}
signed main(){
cin >> n >> q;
for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
while(q--){
int t, ans = 0;
cin >> t >> x1 >> y1;
if(t == 1){
mp.clear();
for(int i = 1; i <= n; i++) ans += mp[calc(x[i] - x1, y[i] - y1)]++;
cout << ans << '\n';
} else{
cin >> x2 >> y2; int cof = 1;
if(crs(2) < crs(1)) cof = -1;
int l = 1, r = n;
while(l < r){
int mid = l + r + 1 >> 1;
if(crs(1) * cof > crs(mid) * cof) r = mid - 1;
else l = mid;
}
cout << slv(1, l, cof) + slv(l + 1, n, -cof) << '\n';
}
}
return 0;
}
详细
answer.code:7:34: error: ‘long long int y1’ redeclared as different kind of entity 7 | int n, q, x[N], y[N], id[N], x1, y1, x2, y2; | ^~ In file included from /usr/include/features.h:461, from /usr/include/x86_64-linux-gnu/c++/13/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/c++config.h:679, from /usr/include/c++/13/cassert:43, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:33, from answer.code:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:221:1: note: previous declaration ‘double y1(double)’ 221 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ answer.code: In function ‘long long int crs(long long int)’: answer.code:16:74: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | int crs(int id){ return (x1 - x[id]) * (y2 - y[id]) - (x2 - x[id]) * (y1 - y[id]);} | ~~~^~~~~~~ answer.code:16:68: error: invalid operands of types ‘long long int’ and ‘double (*)(double) noexcept’ to binary ‘operator*’ 16 | int crs(int id){ return (x1 - x[id]) * (y2 - y[id]) - (x2 - x[id]) * (y1 - y[id]);} | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ | | | | long long int double (*)(double) noexcept answer.code: In function ‘int main()’: answer.code:30:32: error: no match for ‘operator>>’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘double(double) noexcept’) 30 | cin >> t >> x1 >> y1; | ~~~~~~~~~~~~~~ ^~ ~~ | | | | | double(double) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} In file included from /usr/include/c++/13/sstream:40, from /usr/include/c++/13/complex:45, from /usr/include/c++/13/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127: /usr/include/c++/13/istream:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 325 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/13/istream:325:7: note: conversion of argument 1 would be ill-formed: answer.code:30:35: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘void*’ [-fpermissive] 30 | cin >> t >> x1 >> y1; | ^~ | | | double (*)(double) noexcept answer.code:30:35: error: cannot bind rvalue ‘(void*)y1’ to ‘void*&’ /usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 201 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:201:7: note: conversion of argument 1 would be ill-formed: answer.code:30:35: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘long long unsigned int’ [-fpermissive] 30 | cin >> t >> x1 >> y1; | ^~ | | | double (*)(double) noexcept answer.code:30:35: error: cannot bind rvalue ‘(long long unsigned int)y1’ to ‘long long unsigned int&’ /usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match) 197 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/13/istream:197:7: note: conversion of argument 1 would be ill-formed: answer.code:30:35: error: invalid conversion from ‘double (*)(double) noexcept’ to ‘long long int’ [-fpermissive] 30 | cin >> t >> x1 >> y1; | ^~ | | | double (*)(double) noexcept answer.code:30:35: error: cannot bind rvalue ‘(long long int)y1’ to ‘long long int&’ /usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsi...