QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#601402#9319. Bull FarmChyuhWA 175ms42880kbC++171.9kb2024-09-29 23:00:072024-09-29 23:00:09

Judging History

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

  • [2024-09-29 23:00:09]
  • 评测
  • 测评结果:WA
  • 用时:175ms
  • 内存:42880kb
  • [2024-09-29 23:00:07]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, l, q;
struct ty{
    int a, b, c;
};
vector<ty> qust[N];
vector<bitset<2005> > g(2005);
int t[2005][2005];
int ans[N];
int input(){
    char c1, c2;
    cin >> c1 >> c2;
    c1 -= 48;
    c2 -= 48;
    return c1 * 50 + c2;
}
void add(int a, int b){
    if(g[a][b]) return;
    for(int i = 1; i <= n; i++){
        if(g[i][a]){
            g[i] |= g[b];
        }
    }
}
void cal(int cur){
    vector<int> cnt(n + 1);
    vector<int> p;
    for(int i = 1; i <= n; i++){
        if(cnt[t[cur][i]]){
            p.push_back(t[cur][i]);
        }
        cnt[t[cur][i]]++;
    }
    if(p.empty()){
        for(int i = 1; i <= n; i++){
            add(i, t[cur][i]);
        }
    }else{
        if(p.size() == 1){
            int pos = 0;
            for(int i = 1; i <= n; i++){
                if(!cnt[i]){
                    pos = i;
                }
            }
            for(int i = 1; i <= n; i++){
                if(t[cur][i] == p[0]){
                    add(i, pos);
                }
            }
        }
    }
}
void solve(){
    cin >> n >> l >> q;
    for(int i = 0; i <= n; i++){
        g[i].reset();
        g[i][i] = 1;
    }
    for(int i = 1; i <= l; i++){
        for(int j = 1; j <= n; j++){
            t[i][j] = input();
        }
    }
    for(int i = 1; i <= q; i++){
        int a = input(), b = input(), c = input();
        qust[c].push_back({a, b, i});
    }
    for(int i = 0; i <= l; i++){
        cal(i);
        for(auto [a, b, pos] : qust[i]){
            ans[pos] = g[a][b];
        }
    }
    for(int i = 1; i <= q; i++){
        cout << ans[i];
    }
    cout << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin >> T;
    while(T--){
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3ms
memory: 30536kb

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: 175ms
memory: 42880kb

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:

011110001101101111111111111111111101111111110111011110110110111011010111111111111111111101111111111110111111110111111111111101111111111110111111111111111111110001100111111111111111111111111011101111111111111111111111111111111111111111011011110100111110111111110111111100111111101110111111111101111110...

result:

wrong answer 2nd lines differ - expected: '111111011101111011011111111111...1111110111111110111011110101111', found: '111111111101111111111111111111...1111111111111110111111111111111'