QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#521632#7042. So EasyQFshengxiu#WA 0ms3820kbC++201.8kb2024-08-16 13:28:232024-08-16 13:28:24

Judging History

你现在查看的是最新测评结果

  • [2024-08-16 13:28:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2024-08-16 13:28:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define lowbit(x) (x & (-x))
#define all(x) x.begin(), x.end()
#define inf 0x3f3f3f3f3f3f3f3f
#define int long long
#define pai 3.14
#define QF ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define c1 cout << 1
#define c2 cout << 2
// #define width cout << ""
using ll = long long;
using PII = pair<int, int>;
using LD = long double;

mt19937_64 rnd(chrono::duration_cast<chrono::nanoseconds>(chrono::system_clock::now().time_since_epoch()).count());
constexpr int N = 1e3 + 10;
int a[N][N], row[N], col[N];
void solve()
{
    int n;
    cin >> n;
    int rows, cols;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            cin >> a[i][j];
            if (a[i][j] == -1)
            {
                rows = i;
                cols = j;
            }
        }
    }
    int flag1 = 0, flag2 = 0, minn = inf, minn2 = inf;
    for (int i = 1; i <= n; i++)
    {
        if (i == cols)
            continue;
        if (a[rows][i] == 0)
        {
            flag1 = 1;
            continue;
        }
        minn = min(minn, a[rows][i]);
    }
    for (int i = 1; i <= n; i++)
    {
        if (i == rows)
            continue;
        if (a[i][cols] == 0)
        {
            flag2 = 1;
            continue;
        }
        minn2 = min(minn2, a[i][cols]);
    }
    if (!flag1)
        cout << minn << endl;
    else
        cout << minn2 << endl;
}
signed main()
{
    QF;
    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve();
        // cout << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3820kb

input:

3
1 2 1
0 -1 0
0 1 0

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3716kb

input:

10
63 66 64 39 41 64 67 46 45 56
67 70 68 43 45 68 71 50 49 60
72 75 73 48 50 73 76 55 54 65
64 67 65 40 42 65 68 47 46 57
81 84 82 57 59 82 85 64 63 74
43 46 44 19 21 44 47 26 25 36
45 48 46 21 23 -1 49 28 27 38
70 73 71 46 48 71 74 53 52 63
57 60 58 33 35 58 61 40 39 50
81 84 82 57 59 82 85 64 63 74

output:

21

result:

wrong answer 1st numbers differ - expected: '46', found: '21'