QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#569091#9319. Bull Farmnan01WA 30ms4012kbC++202.8kb2024-09-16 20:27:032024-09-16 20:27:04

Judging History

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

  • [2024-09-16 20:27:04]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:4012kb
  • [2024-09-16 20:27:03]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define ll long long
#define pii pair<int, int>
#define inf 0x3f3f3f3f
#define fi first
#define pll pair<ll, ll>
#define se second
#define lll __int128
#define ld long double
#define all(a) a.begin() + 1, a.end()
#define iofast                   \
    ios::sync_with_stdio(false); \
    cin.tie(0), cout.tie(0)
#define lowbit(i) (i & (-i))
using namespace std;
const int maxn = 1e6 + 5, mod = 1000000007;
void solve()
{
    int n, l, q;
    cin >> n >> l >> q;
    vector tong(l + 1, vector<pii>());
    for (int i = 1; i <= l; i++)
    {
        string s;
        cin >> s;
        vector<int> in(n + 1);
        int cnt = n;
        int zhuang = 0;
        for (int j = 0, id = 1; j < s.length(); j += 2, id++)
        {
            auto x = (s[j] - '0') * 50 + s[j + 1] - '0';
            cnt -= !in[x]++;
            tong[i].push_back(pair{id, x});
            if (in[x] == 2)
                zhuang = x;
            else if (in[x] == 3)
                zhuang = -1;
        }
        if (cnt == 0)
        {
            continue;
        }
        else if (cnt == 1 && ~zhuang)
        {
            auto yuan = -1;
            for (int j = 1; j <= n; j++)
            {
                yuan = !in[j] ? j : yuan;
            }
            vector<pii> tmp;
            for (auto [j, k] : tong[i])
            {
                if (in[k] == 2)
                {
                    tmp.push_back(pair{j, yuan});
                }
            }
            tmp.swap(tong[i]);
        }
        else
            tong[i].clear();
    }
    vector qry(l + 1, vector<array<int, 3>>());
    for (int i = 1; i <= q; i++)
    {
        string s;
        cin >> s;
        auto a = (s[0] - '0') * 50 + s[1] - '0';
        auto b = (s[2] - '0') * 50 + s[3] - '0';
        auto c = (s[4] - '0') * 50 + s[5] - '0';
        qry[c].push_back(array{a, b, i});
    }
    vector<bitset<2002>> in(n + 1), out(n + 1);
    for (int i = 1; i <= n; i++)
    {
        in[i][i] = 1;
        out[i][i] = 1;
    }
    string ans = string(q + 1, '0');
    rep(i, 0, l)
    {
        for (auto [u, v] : tong[i])
        {
            if (out[u][v])
                continue;
            for (int j = 1; j <= n; j++)
            {
                if (in[u][j])
                {
                    out[j] |= out[v];
                }
            }
        }
        for (auto [a, b, id] : qry[i])
        {
            ans[id] = out[a][b] ? '1' : '0';
        }
    }
    cout << ans.substr(1, q) << "\n";
}
int main()
{
    iofast;
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    // cout << endl;
    //  system("pause");
}

詳細信息

Test #1:

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

input:

2
5 2 4
0305040201
0404040404
030300
020500
050102
020501
6 2 4
030603010601
010203060504
030202
060402
050602
060401

output:

1011
0100

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

1
3 3 6
020202
030301
030201
020102
030203
010201
010303
020303
010202

output:

010101

result:

ok single line: '010101'

Test #3:

score: -100
Wrong Answer
time: 30ms
memory: 4012kb

input:

200
10 10 5000
01060:04020305080709
0103070:060204050908
09070503080401060:02
050308010204090:0607
03010502040607080:09
03080109020504060:07
06050:09040302080107
07080305010409060:02
030809010:0204060507
0:060908070201050304
060700
090:03
09080:
070405
010703
0:0100
080601
030600
070206
0:0:09
08040...

output:

011110001101101111111110110111100101011100010101010100110110101010010001011111011111010101111101110110001001110111110111111101011111111110010111111001111111110001100111001111111111111101111011001110111001111111011011011011111111111111011011010100111110111011100011011100101111001110101111010001100110...

result:

wrong answer 1st lines differ - expected: '011110001101101111111111111111...1111111111111111101111111111111', found: '011110001101101111111110110111...1111101101111100100011111101011'