QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#325463#7951. Magic Cardsmateberishvili#WA 24ms7448kbC++231.5kb2024-02-11 14:08:212024-02-11 14:08:21

Judging History

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

  • [2024-02-11 14:08:21]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:7448kb
  • [2024-02-11 14:08:21]
  • 提交

answer

#include<bits/stdc++.h>

#define pb push_back

typedef long long ll;

using namespace std;

int main(){
  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
  ll n, k, m, f;
  
  cin >> n >> k >> m >> f;
  vector<vector<ll>>nums(k);
  
  unordered_map<ll,bool>is;
  ll newNum = 0;
  
  for(ll i = 0; i < k; i++){
    for(ll j = 0; j < m; j++){
      ll a;
      cin >> a;
      nums[i].pb(a);
      if(!is[a])newNum++;
      is[a] = true;
    }
  }
  
  ll allNo = 1;
  if(newNum == n - 1){
    while(is[allNo]){
      allNo++;
    }
  }else{
    allNo = 0;
  }
  
  for(ll i = 0; i < f; i++){
    string s;
    cin >> s;
    ll ly = -1, ny = 0, nny= 0;
    vector<ll>fix(n + 1, 0);
    ll q = 1;
    for(ll j = 0; j < s.size(); j++){
      unordered_map<ll,bool>was;
      if(s[j] == 'Y'){
        ly = j;nny++;
        for(ll el : nums[j]){
          if(!was[el])fix[el]++;
          was[el] = true;
        }
      }else{
        for(ll el : nums[j]){
          if(fix[el] >= 0)ny++;
          fix[el] = -2 * f;
          
        }
      }
    }
    
    if(ly == -1){
      cout << allNo << endl;
    }else{
      ll ans = -1;
      for(ll el : nums[ly]){
        if(fix[el] == nny){
          if(ans == -1)ans = el;
          else {
//            cout << ans << " " << el;
            ans = 0;
            break;
          }
        }
      }
      cout << ans << endl;
    }
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3524kb

input:

12 4 6 3
1 9 7 11 3 5
2 10 3 6 7 11
4 5 6 7 6 12
8 11 10 9 12 9
YYNY
NNNY
YNNN

output:

11
8
1

result:

ok 3 lines

Test #2:

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

input:

13 4 6 4
1 9 7 11 3 5
2 10 3 6 7 11
4 5 6 7 6 12
8 11 10 9 12 9
YYNY
NNNY
YNNN
NNNN

output:

11
8
1
13

result:

ok 4 lines

Test #3:

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

input:

14 4 6 4
1 9 7 11 3 5
2 10 3 6 7 11
4 5 6 7 6 12
8 11 10 9 12 9
YYNY
NNNY
YNNN
NNNN

output:

11
8
1
0

result:

ok 4 lines

Test #4:

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

input:

1 1 1 1
1
Y

output:

1

result:

ok single line: '1'

Test #5:

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

input:

1 100 1 1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY...

output:

1

result:

ok single line: '1'

Test #6:

score: -100
Wrong Answer
time: 24ms
memory: 7448kb

input:

1 100 5000 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'