QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#437236 | #8782. Schoolgirls | ucup-team3099# | WA | 3ms | 4032kb | C++23 | 5.1kb | 2024-06-09 06:49:37 | 2024-06-09 06:49:37 |
Judging History
answer
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <algorithm>
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
const long double PI = acosl(-1);
const long double EPS = 1e-8;
struct PT {
typedef long double T;
T x, y;
PT(T _x = 0, T _y = 0) : x(_x), y(_y){}
PT operator +(const PT &p) const { return PT(x+p.x,y+p.y); }
PT operator -(const PT &p) const { return PT(x-p.x,y-p.y); }
PT operator *(T c) const { return PT(x*c,y*c); }
PT operator /(long double c) const { return PT(x/c,y/c); }
T operator *(const PT &p) const { return x*p.x+y*p.y; }
T operator %(const PT &p) const { return x*p.y-y*p.x; }
T operator !() const { return sqrtl(x*x+y*y); }
T operator ^(const PT &p) const { return atan2l(*this%p, *this*p);}
bool operator < (const PT &p) const { return x != p.x ? x < p.x : y < p.y; }
//bool operator == (const PT &p)const { return x == p.x && y == p.y; }
friend std::ostream& operator << (std::ostream &os, const PT &p) {
return os << p.x << ' ' << p.y;
}
friend std::istream& operator >> (std::istream &is, PT &p) {
return is >> p.x >> p.y;
}
};
int main() {
std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
int n, m, q;
std::cin >> n >> m >> q;
std::vector<PT> points;
for(int i = 0; i < n; i++) {
points.emplace_back(1000 * cosl(2 * PI * i / n), 1000 * sinl(2 * PI * i / n));
}
while(m--) {
int a, b, c;
std::cin >> a >> b >> c;
a--;b--;c--;
points.push_back(points[c] + points[a] - points[b]);
}
while(q--) {
int sz;
std::cin >> sz;
std::vector<PT> hull(sz);
PT center;
for(int i = 0; i < sz; i++) {
int id;
std::cin >> id;
assert(1 <= id && id <= (int) points.size());
hull[i] = points[id-1];
center = center + hull[i];
}
center = center / sz;
long double dist = !(hull[0] - center);
bool good = true;
PT pivot = hull[0];
for(int i = 0; i < sz; i++) {
good = good && std::abs((!(hull[i] - center)) - dist) <= EPS;
pivot = std::min(pivot, hull[i]);
}
if(dist <= EPS && good) {
std::cout << "Yes\n";
continue;
}
for(int i = 0; i < sz; i++) {
hull[i] = hull[i] - pivot;
}
center = center - pivot;
for(int i = 0; i < sz; i++) {
if((!hull[i]) < (!hull[0])) {
std::swap(hull[0], hull[i]);
}
}
std::sort(hull.begin() + 1, hull.end(), [&](PT a, PT b) { return a % b < 0; });
for(int i = 0; i < sz; i++) {
good = good && std::abs((hull[i] - center) % (hull[(i+1)%sz] - center) - (hull[(i+1)%sz] - center) % (hull[(i+2)%sz] - center)) <= 1e-5;
}
std::cout << (good ? "Yes\n" : "No\n");
}
}
/*
NEVER FORGET TO:
Look at the problem's constraints before coding.
How to cheese cf:
Find a lower bound or upper bound for the problem. Have faith that it is the answer of the problem.
If it isn't the answer, have more faith or change to another bound god by looking for a better bound.
Trust guesses. Who has time to think? If people in div2 AC the problem it requires no proof since people don't prove things.
You must draw cases. Thinking gets you nowhere, so draw cases and reach illogical conclusions from them.
Sometimes drawing cases is bad because it takes too much time. Faster is to not think at all and just code a bruteforce solution.
This is called "law of small numbers". If something works for small numbers, surely it works for big numbers.
https://en.wikipedia.org/wiki/Faulty_generalization#Hasty_generalization don't mind the "faulty" part of it, in competitive programming mistakes are lightly punished
Don't think about them being right or not, cf is a battle of intuition only.
Be as stupid as possible in implementation. Trying to be smart is an easy way to get WA.
Think about 2x2 cases for matrix problems and hope that everything works for the general case.
Find a necessary condition and trust it to be sufficient. They're basically the same thing.
Heuristics might speed up your code. Forget about complexity, it's only about ACing and not proving that your solution is good.
For paths in a grid starting at (1, i) or something like that, assume that they never cross and do D&C
Consider doing problems in reverse order of queries/updates
For combinatorics problems, consider symmetry
General strategy (MUST DO):
Try to solve the problem with more restricted constraints.
About testing:
Test n=1, a[i]=1, a[i]=n, etc. Basically, test low values. No need to test if pretests are strong, but if you get WA it's good.
This isn't a joke. Do it if you get stuck. It's shit practice in my opinion, but do it if you want AC.
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4028kb
input:
3 6 8 1 2 3 3 1 4 5 4 3 3 1 2 4 5 3 4 5 2 6 4 7 6 5 1 2 3 1 3 2 3 1 1 8 4 2 5 6 7 3 2 1 4 3 6 5 9 3 4 7 9 4 1 3 2 8
output:
Yes Yes Yes No No No Yes No
result:
ok 8 token(s): yes count is 4, no count is 4
Test #2:
score: 0
Accepted
time: 1ms
memory: 4032kb
input:
12 0 1 12 12 11 10 9 8 7 6 5 4 3 2 1
output:
Yes
result:
ok YES
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 3868kb
input:
3 0 6685 5 1 3 1 2 2 3 1 2 3 5 3 1 3 3 1 4 1 1 1 3 3 3 2 1 5 2 3 2 1 3 6 2 2 3 2 3 1 5 3 1 2 3 2 3 3 3 2 5 3 2 2 2 3 5 2 2 3 3 1 6 3 3 1 3 1 3 6 2 3 3 2 2 1 5 2 2 3 2 2 6 2 3 3 2 1 3 6 2 2 2 2 1 3 3 3 1 2 4 3 2 1 1 5 3 1 3 2 3 4 3 1 1 2 4 2 2 2 3 3 1 2 2 4 2 3 3 1 3 2 2 2 4 1 2 2 3 3 3 3 3 4 1 3 1 3...
output:
No Yes No No Yes No No No No No No No No No No No Yes No No No No No No Yes No Yes Yes No No No No No No No No No No No Yes No No No No No No Yes No Yes No No No No No Yes No Yes No No No Yes No No No No No No Yes No No No No No No No No No No Yes No No No No No No No No No No No No Yes No No No No ...
result:
wrong answer expected NO, found YES [27th token]