QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#353002 | #4234. Tic Tac Toe Counting | PetroTarnavskyi# | RE | 0ms | 0kb | C++20 | 1.3kb | 2024-03-13 19:34:44 | 2024-03-13 19:34:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int N = 1047;
const int K = 11;
int dp[N][N][K];
vector<PII> e[K];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, k, c;
cin >> n >> k >> c;
FOR (i, 0, c)
{
int a, b, d;
cin >> a >> b >> d;
a--, b--, d--;
e[d].PB({a, b});
}
FOR (sick, 0, n)
{
FOR (koniara, 0, n)
{
if (sick == koniara)
continue;
dp[sick][koniara][0] = 1;
}
}
FOR (d, 0, k - 1)
{
for (auto p : e[d])
{
FOR (koni, 0, n)
{
if (koni == p.F || koni == p.S)
continue;
if (dp[p.F][koni][d] && dp[p.F][p.S][d])
dp[p.S][koni][d + 1] = 1;
if (dp[p.S][koni][d] && dp[p.S][p.F][d])
dp[p.F][koni][d + 1] = 1;
}
}
}
set<int> ans;
for (auto p : e[k - 1])
{
if (dp[p.F][p.S][k - 1])
ans.insert(p.S + 1);
if (dp[p.S][p.F][k - 1])
ans.insert(p.F + 1);
}
cout << SZ(ans) << '\n';
for (auto a : ans)
cout << a << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
4 XX..O.... X...OX... OOOX.X.X. OOOXXX...