QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#66130#5161. Last Guessfeeder1#TL 9ms3680kbC++142.0kb2022-12-07 00:09:382022-12-07 00:09:41

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-07 00:09:41]
  • 评测
  • 测评结果:TL
  • 用时:9ms
  • 内存:3680kb
  • [2022-12-07 00:09:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

set<ll> cmi[30], ez[30];
ll minx[30], cnt[30], curL[505];
vector<ll> aj[30];
bool maxn[30], vis[30];
bool aug(ll x) {
 if ( vis[x] )return false;
 vis[x] = true;
 for ( auto it : aj[x] ) {
  int a;
  if ( curL[it] == -1 || aug(curL[it]) ) {
   curL[it] = x;
   return true;
  }
 }
 return false;
}
int main() {
 ios::sync_with_stdio(0);
 cin.tie(0);
 int n, m, i, j, k, b, c, a;
 cin >> n >> m;
 for ( i = 0; i < m; i++ )curL[i] = -1;
 string str, str2;
 for ( i = 0; i < n - 1; i++ ) {
  cin >> str >> str2;
  for ( j = 0; j < 26; j++ )cnt[j] = 0;
  for ( j = 0; j < str.size(); j++ ) {
   a = str[j] - 'a';
   if ( str2[j] == 'G' ) {
    curL[j] = a;
    cnt[a]++;
    ez[a].insert(j);
    cmi[a].insert(j);
   } else if ( str2[j] == 'Y' ) {
    cnt[a]++;
    cmi[a].insert(j);
   } else {
    cmi[a].insert(j);
    maxn[a] = true;
   }
  }
  for ( j = 0; j < 26; j++ )minx[j] = max(minx[j], cnt[j]);
 }
 for ( i = 0; i < 26; i++ ) {
  for ( j = 0; j < m; j++ ) {
   if ( cmi[i].find(j) != cmi[i].end() )continue;
   if ( curL[j] != -1 )continue;
   aj[i].push_back(j);
  }
 }
 for ( i = 0; i < 26; i++ ) {
  for ( k = 0; k < minx[i] - ez[i].size(); k++ ) {
   for ( j = 0; j < 26; j++ )vis[j] = false;
   vis[i] = true;
   for ( auto it : aj[i] ) {
    if ( curL[it] == -1 || aug(curL[it]) ) {
     curL[it] = i;
     break;
    }
   }
  }
 }
 ll cnt2 = 0;
 for ( i = 0; i < m; i++ ) {
  if ( curL[i] == -1 )cnt2++;
 }
 for ( i = 0; i < 26 && cnt2; i++ ) {
  if ( maxn[i] )continue;
  while ( cnt2 ) {
   for ( j = 0; j < 26; j++ )vis[j] = false;
   vis[i] = true;
   bool done = false;
   for ( auto it : aj[i] ) {
    if ( curL[it] == -1 || aug(curL[it]) ) {
     curL[it] = i;
     done = true;
     break;
    }
   }
   if ( !done )break;
   cnt2--;
  }
 }
 for ( i = 0; i < m; i++ ) {
  char ch = curL[i] + 'a';
  cout << ch;
 }
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 3272kb

input:

4 5
reply YYGBB
refer BBBGG
puppy YYGBB

output:

upper

result:

ok 

Test #2:

score: 0
Accepted
time: 3ms
memory: 3384kb

input:

2 12
aabbccddeeff GGGYGBYYYBBB

output:

aabacaaaddeb

result:

ok 

Test #3:

score: 0
Accepted
time: 6ms
memory: 3580kb

input:

25 500
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqoqqqqqqqqqqqqqqqqqqqqqqoqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqjq...

output:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqgqqqqq...

output:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok 

Test #6:

score: 0
Accepted
time: 6ms
memory: 3568kb

input:

22 500
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccoccccccccccccccccccccccccccccccccccccccccccccccccfccccccccccccccccccccccccccccccccc...

output:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaafaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

result:

ok 

Test #7:

score: -100
Time Limit Exceeded

input:

30 20
azzzzzzzzzzzzzzzzzzz YBBBBBBBBBBBBBBBBBBB
zazzzzzzzzzzzzzzzzzz BGBBBBBBBBBBBBBBBBBB
zzazzzzzzzzzzzzzzzzz BBYBBBBBBBBBBBBBBBBB
zzzazzzzzzzzzzzzzzzz BBBYBBBBBBBBBBBBBBBB
zzzzazzzzzzzzzzzzzzz BBBBGBBBBBBBBBBBBBBB
zzzzzazzzzzzzzzzzzzz BBBBBYBBBBBBBBBBBBBB
zzzzzzazzzzzzzzzzzzz BBBBBBYBBBBBBBBBBBBB
...

output:


result: