結果
| 問題 |
No.2268 NGワード回避
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-16 13:51:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 1,124 bytes |
| コンパイル時間 | 863 ms |
| コンパイル使用メモリ | 91,232 KB |
| 最終ジャッジ日時 | 2025-02-12 09:12:23 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 52 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:36:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
36 | scanf("%s", ib);
| ~~~~~^~~~~~~~~~
ソースコード
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;
bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
class mypcmp {
public:
bool operator()(const int& a, const int& b) {
return a<b;
}
};
char ib[1024];
char ob[1024];
int main() {
int n, i, v, j;
scanf("%d", &n);
set<int> vs;
int mn = min(30, n);
int mm = 1<<mn;
for (i=0; i<n; i++) {
scanf("%s", ib);
v=0; for (j=0; j<mn; j++) {
v*=2; if (ib[j]=='b') v++;
}
// for (; j<30; j++) v*=2;
// printf("insert %d\n", v);
vs.insert(v);
}
for (v=0; v<mm; v++) {
if (vs.count(v)) continue;
for (j=mn-1; j>=0; j--) {
if (v&1) ob[j]='b';
else ob[j]='a';
v>>=1;
}
break;
}
j=mn; while(j<n) ob[j++]='a';
ob[n]=0;
printf("%s\n", ob);
return 0;
}