Submission

Status:
[P][P][P][P][P][PP][PP][PP][PP][PP]

Score: 100

User: Winzzwz

Problemset: การแข่งขัน

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-09 00:14:27

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int n,c,t[40][40];
queue<int> qu;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> c;
    for (int i = 1; i <= n; i++) {
        qu.push(i);
        for (int j = 1; j <= n; j++) {
            cin >> t[i][j];
        }
    }
    while (qu.size() > 1) {
        for (int i = 1; i <= qu.size()/2; i++) {
            int team1 = qu.front(); qu.pop();
            int team2 = qu.front(); qu.pop();
            if (t[team1][team2] == team1) {
                if (c == team2) {qu.push(team2); c = -1; continue;}
                qu.push(team1);
            } else {
                if (c == team1) {qu.push(team1); c = -1; continue;}
                qu.push(team2);
            }
        }
    }
    cout << qu.front();
    return 0;
}