QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#320406#8209. Curly Palindromesucup-team197#WA 1ms3700kbC++201.0kb2024-02-03 16:25:502024-02-03 16:25:51

Judging History

This is the latest submission verdict.

  • [2024-02-03 16:25:51]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3700kb
  • [2024-02-03 16:25:50]
  • Submitted

answer

#include <iostream>

using namespace std;
typedef long long ll;

const int N = 100 + 3;

ll n;
pair<ll, ll> p[N];
char c[N];

ll cross(pair<ll, ll> a, pair<ll, ll> b){
    return a.first * b.second - b.first * a.second;
}

pair<ll, ll> subtract(pair<ll, ll> a, pair<ll, ll> b){
    return pair{a.first - b.first, a.second - b.second};
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> p[i].first >> p[i].second >> c[i];

    if(n <= 2){
        cout << n << "\n";
        return 0;
    }

    bool on_line = true;
    for(int i = 2; i < n; ++i){
        on_line &= !cross(subtract(p[i - 1], p[i - 2]), subtract(p[i], p[i - 2]));
    }

    bool same_c = false;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            if(c[i] == c[j]){
                same_c = true;
            }
        }
    }

    if(on_line || !same_c){
        cout << "2\n";
        return 0;
    }

    cout << "Infinity\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3700kb

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

input:

3
2 3 e
3 2 e
8 9 e

output:

Infinity

result:

ok single line: 'Infinity'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3700kb

input:

3
0 0 p
1 1 c
2 2 o

output:

2

result:

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