結果
| 問題 | No.2042 RGB Caps |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-11-05 17:23:21 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,039 bytes |
| 記録 | |
| コンパイル時間 | 2,387 ms |
| コンパイル使用メモリ | 348,588 KB |
| 実行使用メモリ | 10,060 KB |
| 最終ジャッジ日時 | 2026-07-16 08:17:47 |
| 合計ジャッジ時間 | 5,465 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 3 WA * 13 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/string:44,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bitset:54,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:54,
from main.cpp:1:
In static member function 'static constexpr void std::char_traits<char>::assign(char_type&, const char_type&)',
inlined from 'constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::push_back(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/basic_string.h:1729:21,
inlined from 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator+=(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/basic_string.h:1499:17,
inlined from 'int main()' at main.cpp:83:43:
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/char_traits.h:352:14: warning: 'last' may be used uninitialized [-Wmaybe-uninitialized]
352 | __c1 = __c2;
| ~~~~~^~~~~~
main.cpp: In function 'int main()':
main.cpp:23:9: note: 'last' was declared here
23 | char last;
| ^~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define nl endl
signed main(){
int n,k; cin >> n >> k;
map<int,char>m;
string ans ="";
set<char>st;
for(int i = 0; i < k; i++){
int x; cin >> x;
char c; cin >> c;
m[x] = c;
st.insert(c);
}
vector<char>v(st.begin(),st.end());
char last;
vector<char>check;
for(auto [x,y]: m){
last = y;
check.push_back(y);
}
char ss = check[check.size() - 1];
int ii = check.size() - 1;
while(check[ii] == ss){
ii--;
}
char slast = check[ii];
int c1 = 0, c2 = 0, c3 = 0;
if(st.size() == 1){
for(int i = 0; i < n; i++) ans += *st.begin();
cout << ans << nl;
}
else if(st.size() == 2){
int prev = 0;
for(auto &it : m){
char xx;
if(v[0] == it.second) xx = v[1];
else xx = v[0];
int x = it.first - prev;
int soto = x/2;
int boro = x - soto;
int i;
for(i = 0; i < boro; i++) ans+=it.second;
for(i = 0; i < soto; i++) ans+=xx;
prev = it.first;
}
if(ans.size() < n){
while(ans.size()!=n){
ans += last;
}
}
cout << ans << nl;
}
else{
int prev = 0;
for(auto &it : m){
char xx;
if(v[0] == it.second) xx = v[1];
else xx = v[0];
int x = it.first - prev;
int soto = x/2;
int boro = x - soto;
int prothom = soto/2;
int ditio = soto - prothom;
int i;
for(i = 0; i < boro; i++) ans+=it.second;
for(i = 0; i < prothom; i++) ans+=slast;
for(i = 0; i <ditio; i++) ans+=last;
prev = it.first;
}
if(ans.size() < n){
while(ans.size()!=n){
ans += last;
}
}
cout << ans << nl;
}
}
vjudge1