#54499: C++解答


kita197 (aries)


#include<iostream>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    int s, t, a1, a2, b1, b2, c1, c2;
    while (n--) {
        cin >> s >> t >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;
        if (s == t)
            cout << "0\n";
        else if ((s == a1 && t == a2) || (s == a2 && t == a1) ||
                 (s == b1 && t == b2) || (s == b2 && t == b1) ||
                 (s == c1 && t == c2) || (s == c2 && t == c1))
            cout << "2\n";
        else
            cout << "1\n";
    }
    return 0;
}

#54506: Re: C++解答


s10900156@nhsh.tp.edu.tw (ShanC)


#include
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    int s, t, a1, a2, b1, b2, c1, c2;
    while (n--) {
        cin >> s >> t >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;
        if (s == t)
            cout << "0\n";
        else if ((s == a1 && t == a2) || (s == a2 && t == a1) ||
                 (s == b1 && t == b2) || (s == b2 && t == b1) ||
                 (s == c1 && t == c2) || (s == c2 && t == c1))
            cout << "2\n";
        else
            cout << "1\n";
    }
    return 0;
}

直接貼答案是絕對無法領悟螺旋之力的精髓

同樣地,別靠 AI 了請自己觀察

明明就很簡單