| Task: | Peli |
| Sender: | adex720 |
| Submission time: | 2024-01-20 16:59:27 +0200 |
| Language: | C++ (C++11) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:50:13: warning: init-statement in selection statements only available with '-std=c++17' or '-std=gnu++17'
50 | if (a== b && (x&2==0){
| ^
input/code.cpp:50:26: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
50 | if (a== b && (x&2==0){
| ~^~~
input/code.cpp:50:30: error: expected ';' before '{' token
50 | if (a== b && (x&2==0){
| ^
| ;
input/code.cpp:50:19: warning: statement has no effect [-Wunused-value]
50 | if (a== b && (x&2==0){
| ~~~~~~^~~~~~~~~~~
input/code.cpp:55:32: error: expected initializer before ';' token
55 | queue<pair<int, int>> q;
| ^
input/code.cpp:55:32: error: expected ')' before ';' token
55 | queue<pair<int, int>> q;
|...Code
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#define MP make_pair
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, kyselyja, x, a, b;
cin >> n >> m >> kyselyja;
vector<int> v[n];
for (int i = 0; i < m; i++)
{
cin >> a >> b;
a--;
b--;
v[a].push_back(b);
v[b].push_back(a);
}
bool parillinen[n];
bool pariton[n];
for (int i = 0; i < kyselyja; i++)
{
cin >> a >> b >> x;
a--;
b--;
if (x == 0)
{
if (a == b)
{
cout << "YES\n";
}
else
{
cout << "NO\n";
}
continue;
}
if (a== b && (x&2==0){
cout << "YES\n";
continue;
}
queue<pair<int, int>> q;
fill(parillinen, parillinen + n, 0);
fill(pariton, pariton + n, 0);
parillinen[a] = 1;
for (int t : v[a])
{
q.push(MP(t, 1));
// pariton[t] = 1;
}
while (true)
{
if (q.empty())
{
cout << "NO\n";
break;
}
auto p = q.front();
q.pop();
int index = p.first;
int d = p.second;
if (d > x)
{
cout << "NO\n";
break;
}
if ((d & 1))
{
if (pariton[index])
{
continue;
}
pariton[index] = 1;
}
else
{
if (parillinen[index])
{
continue;
}
parillinen[index] = 1;
}
if (index == b && (x & 1) == (d & 1))
{
cout << "YES\n";
break;
}
for (int t : v[index])
{
q.push(MP(t, d + 1));
}
}
}
}