社区讨论
暴力if判断,乱输出 求调 玄关
P1105平台参与者 2已保存回复 4
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 4 条
- 当前快照
- 1 份
- 快照标识符
- @lymx5vmp
- 此快照首次捕获于
- 2024/07/15 19:46 2 年前
- 此快照最后确认于
- 2024/07/15 20:29 2 年前
思路图:

CPP
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
#define coutdouble(a, b) cout << fixed << setprecision(a) << (b)
#define ll long long
#define endl '\n'
using namespace std;
const int N = 1e4 + 5;
const int INF = 0x3f3f3f;
const int INFS = -0x3f3f3f;
int n;
struct platform
{
int no, h, l, r;
} a[N];
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i].h >> a[i].l >> a[i].r;
a[i].no = i;
}
for (int i = 1; i <= n; i++)
{
if (a[i].h == 1) cout << "0 0" << endl;
else
{
for (int l = 1; l <= n; l++)
{
if (a[i].h == a[l].h) cout << 0 << " ";
else if (a[i].l == a[l].r) cout << a[l].no << " ";
else if (a[i].r > a[l].r && a[i].l < a[l].r && a[l].l < a[i].l) cout << a[l].no << " ";
else if (a[i].r == a[l].r && a[l].l < a[i].l) cout << a[l].no << " ";
else cout << 0 << " ";
}
for (int r = 1; r <= n; r++)
{
if (a[i].h == a[r].h) cout << 0 << endl;
if (a[i].l == a[r].r) cout << a[r].no << endl;
else if (a[i].l < a[r].l && a[i].r > a[r].l && a[r].r > a[i].r) cout << a[r].no << endl;
else if (a[i].l == a[r].l && a[r].r > a[i].r) cout << a[r].no << endl;
else cout << 0 << endl;
}
}
}
}
signed main()
{
// freopen("../in_out/in.txt", "r", stdin);
// freopen("../in_out/out.txt", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr); // 关闭同步流
int t = 1;
// cin>>t;
while (t--)
{
solve();
}
return 0;
}
回复
共 4 条回复,欢迎继续交流。
正在加载回复...