跳到正文

个人记录

CSP-J 2026 T1 旅游

ai0502约 2 分钟
原文
文章信息与版本

文章信息

发布
2026年11月6日
收录
2026年11月8日
更新
2026年11月15日
篇幅
约 2 分钟

版本

  1. v1当前

解题思路

按题目描述模拟计算即可。

C++
#include <iostream>
using namespace std;
const int N = 1e5 + 5;

string c1, s1, c2, s2;

int main()
{
    //freopen("travel.in", "r", stdin);
    //freopen("travel.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> c1 >> s1 >> c2 >> s2;

    // 同车厢
    if (c1 == c2) cout << 1;
    else cout << 0;

    // 同车厢 and 同排
    string p1 = s1.substr(0, 2);
    string p2 = s2.substr(0, 2);
    if (c1 == c2 and p1 == p2)
        cout << 1;
    else
        cout << 0;

    // 同车厢 and 同排 and 同侧
    char ch1 = s1[2];
    char ch2 = s2[2];
    if (c1 == c2 
        and p1 == p2 
        and ((ch1 == 'A' or ch1 == 'B' or ch1 == 'C') and (ch2 == 'A' or ch2 == 'B' or ch2 == 'C')
        or (ch1 == 'D' or ch1 == 'F') and (ch2 == 'D' or ch2 == 'F')))
        cout << 1;
    else cout << 0;

    // 同车厢 and 同排 and 相邻
    string t = "";
    t += s1[2];
    t += s2[2];

    if (c1 == c2            // 同车厢
        and p1 == p2        // 同排
        and (t == "AB" or t == "BA" or t == "BC" or t == "CB" or t == "DF" or t == "FD"))
        cout << 1;
    else cout << 0;
    cout << endl;
    return 0;
}
原文