이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
auto&operator <<(auto& o, pair<auto, auto> p) {return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator <<(auto& o, auto x)->decltype(x.end(), o) {o<<"{"; for(auto v : x) o<<v<<", "; return o<<"}";}
#define debug(X) cout<<"["#X"]"<<X<<endl;
#else
#define debug(X) {}
#endif
#define int long long
struct vec
{
int x, y;
vec(int _x, int _y)
{
x = _x; y = _y;
}
vec getNorm()
{
vec nw(0, 0);
nw.x = x/__gcd(x, y);
nw.y = y/__gcd(x, y);
return nw;
}
int getPts()
{
vec norm = getNorm();
int mx = x, my = y;
if(norm.x == 0 && norm.y == 0) return 0;
if(norm.x == 0) swap(norm.x, norm.y), swap(mx, my);
return mx / norm.x;
}
bool operator ||(vec& obj)
{
if(obj.getNorm().x == this->getNorm().x && obj.getNorm().y == this->getNorm().y) return true;
return false;
}
};
int operator *(vec& obj1, vec& obj2)
{
return obj1.x*obj2.y - obj1.y*obj2.x;
}
auto&operator <<(auto& o, vec V) {return o<<"["<<V.x<<";"<<V.y<<"]";}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
int prevX, prevY;
vector<vec> vfs;
for(int i=0;i<n;i++)
{
int x, y;
cin>>x>>y;
if(i != 0) vfs.push_back(vec(x-prevX, y-prevY));
prevX = x;
prevY = y;
}
if(n <= 2) {cout<<-1; return 0;}
if(vfs[0] || vfs[1]) {cout<<-1; return 0;}
debug(vfs);
int B = vfs[0].getPts() + vfs[1].getPts() + 1;
int P = abs(vfs[0]*vfs[1]);
int W = P - B + 1;
debug(B); debug(P); debug(W);
cout<<W + B - 1;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp:43:18: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
43 | auto&operator <<(auto& o, vec V) {return o<<"["<<V.x<<";"<<V.y<<"]";}
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |