why this code got wrong answer plz ???
#include <bits/stdc++.h>
using namespace std;
void Online() {
#ifdef Online_Judge
freopen(“in.txt”, “r”, stdin);
freopen(“out.txt”, “w”, stdout);
#endif
}
typedef long long ll;
#define _3isssa ios::sync_with_stdio(false), cin.tie(nullptr) , cout.tie(nullptr);
#define all(x) ((x).begin()), ((x).end())
#define allr(x) ((x).rbegin()), ((x).rend())
#define Forr(i, s) for(auto i:s)
#define For(i, s) for(auto &i:s)
#define clr(v, d) memset(v, d, sizeof(v))
#define sz(v) ((int)((v).size()))
#define Time cerr << “Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs” << “\n”;
const int N = 1e5 + 10, mod = 9511551, OO = 1e8;
double EPS = 1e-10;
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, -1, 1, -1, 1};
void solve() {
int n, m, k;
cin >> n >> m >> k;
while (k–) {
pair<int, int> arr[4];
for (int i = 1; i <= 3; ++i) {
cin >> arr[i].first >> arr[i].second;
}
int row = arr[1].first, col = arr[1].second;
int row1 = arr[2].first, col1 = arr[2].second;
int row2 = arr[3].first, col2 = arr[3].second;
pair<int, int> a[] = {{n, col},
{row, m},
{row, 1},
{col, 1}};
bool flag = false;
for (int i = 0; i < 4; ++i) {
int diff1 = abs(row - a[i].first) + abs(col - a[i].second);
int diff2 = abs(row1 - a[i].first) + abs(col1 - a[i].second);
int diff3 = abs(row2 - a[i].first) + abs(col2 - a[i].second);
if (diff1 < diff2 and diff1 < diff3) {
cout << "YES\n";
flag = true;
break;
}
}
if (!flag)
cout << "NO\n";
}
}
int main() {
Online();
_3isssa
int test = 1;
// cin >> test;
while (test–) {
solve();
}
}
created
last reply
- 1
reply
- 455
views
- 2
users