QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#638108 | #8209. Curly Palindromes | Djangle162857# | WA | 0ms | 3844kb | C++23 | 2.2kb | 2024-10-13 14:55:40 | 2024-10-13 14:55:40 |
Judging History
answer
#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'
#ifdef LOCAL
#define FINISH cerr << "FINISH" << endl;
#else
#define FINISH ;
#endif
#ifdef LOCAL
#define debug(x) cerr << setw(4) << #x << " == " << x << endl
#else
#define debug(x)
#endif
#ifdef LOCAL
#define debugv(x) \
cerr << setw(4) << #x << ":: "; \
for (auto i : x) \
cerr << i << " "; \
cerr << endl
#else
#define debugv(x)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
ostream& operator<<(ostream& out, PII& x)
{
out << x.fir << " " << x.sec << endl;
return out;
}
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int N = 200020;
ll cross(PII x, PII y)
{
return 1ll * x.fir * y.sec - 1ll * x.sec * y.fir;
}
bool judge(PII x, PII y, PII z)
{
PII res1 = {x.fir - y.fir, x.sec - y.sec};
PII res2 = {y.fir - z.fir, y.sec - z.sec};
return cross(res1, res2) == 0ll;
}
void solve()
{
int n;
cin >> n;
vector<PII> a(n + 1);
vector<char> ch(n + 1);
map<int, int> mp;
for (int i = 1; i <= n; i++) {
cin >> a[i].fir >> a[i].sec;
cin >> ch[i];
mp[ch[i]] = 1;
}
if (mp.size() == n) {
cout << "1" << endl;
return;
}
int ans = 2;
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (ch[j] != ch[i])
continue;
for (int k = 1; k <= n; k++) {
if (k == i || k == j)
continue;
if (ch[i] == ch[k]) {
if (!judge(a[i], a[j], a[k])) { // 判断三点共线
cout << "Infinity" << endl;
return;
}
}
else {
if (!judge(a[i], a[j], a[k])) { // 判断三点共线
ans = 3;
}
}
}
for (int k = 1; k <= n; k++) {
if (k == i || k == j)
continue;
for (int l = 1; l <= n; l++) {
if (l == i || l == j || l == k)
continue;
if (!judge(a[i], a[j], a[k]) ||
!judge(a[i], a[j], a[l])) { // 判断三点共线
cout << "Infinity" << endl;
return;
}
}
}
}
}
cout << ans << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
// cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
input:
4 0 0 o 1 1 c 2 2 p 3 3 c
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
3 2 3 e 3 2 e 8 9 e
output:
Infinity
result:
ok single line: 'Infinity'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
3 0 0 p 1 1 c 2 2 o
output:
1
result:
ok single line: '1'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3560kb
input:
3 1000000000 1000000000 a 0 1000000000 b 1000000000 0 a
output:
3
result:
wrong answer 1st lines differ - expected: 'Infinity', found: '3'