QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398174#8209. Curly PalindromesdomovonokWA 0ms3580kbC++141.6kb2024-04-25 03:50:062024-04-25 03:50:06

Judging History

This is the latest submission verdict.

  • [2024-04-25 03:50:06]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3580kb
  • [2024-04-25 03:50:06]
  • Submitted

answer

#include "bits/stdc++.h"
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(x...)
#endif

using ll = long long;
using db = long double;

bool cross(pair<int, int> a, pair<int, int> b) {
    return (ll)a.first * b.first + (ll)a.second * b.second > 0;
}

bool on_line(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
    pair<int, int> ab = {b.first - a.first, b.second - a.second};
    pair<int, int> ac = {c.first - a.first, c.second - a.second};
    return (ll)ab.first * ac.second - (ll)ab.second * ac.first == 0;
}

void solve() {
    int n;
    cin >> n;
    vector<pair<pair<int, int>, char>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first.first >> v[i].first.second >> v[i].second;
    }
    bool f = false;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if (v[i].second == v[j].second) f = true;
            for (int k = 0; k < n; k++) {
                if (i == k || j == k) continue;
                if (v[i].second != v[k].second) continue;
                if (on_line(v[i].first, v[j].first, v[k].first)) continue;
                if (cross(v[i].first, v[j].first) && cross(v[j].first, v[k].first) && cross(v[k].first, v[i].first)) {
                    cout << "Infinity";
                    return;
                }
            }
        }
    }
    if (f) {
        cout << 2;
    } else {
        cout << 1;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int tests = 1;
    // cin >> tests;
    while (tests--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

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: 3548kb

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: 3520kb

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: 3516kb

input:

3
1000000000 1000000000 a
0 1000000000 b
1000000000 0 a

output:

2

result:

wrong answer 1st lines differ - expected: 'Infinity', found: '2'