結果
| 問題 |
No.459 C-VS for yukicoder
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-06-28 16:40:14 |
| 言語 | C++17(gnu拡張) (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 2,068 bytes |
| コンパイル時間 | 2,352 ms |
| コンパイル使用メモリ | 198,340 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-06-28 16:40:20 |
| 合計ジャッジ時間 | 5,845 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 58 |
コンパイルメッセージ
main.cpp: In function ‘void FileIO()’:
main.cpp:7:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | freopen("tetris.in","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:8:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | freopen("tetris.out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function ‘void sunburstfan::solve()’:
main.cpp:71:32: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
71 | if(ans[i][k]>=j)cout<<'#';
| ~~~~~~~~^
main.cpp:70:30: note: within this loop
70 | for(int k=1;k<=3;k++){
| ~^~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
void FileIO(){
freopen("tetris.in","r",stdin);
freopen("tetris.out","w",stdout);
}
namespace sunburstfan{
int n,m,q;
int s[N],a[N],ans[N][3];
char c[N];
bool vis[N];
vector<int> v[N];
void solve(){
cin>>n>>m>>q;
for(int i=1;i<=n;i++){
cin>>(c+1);
for(int j=1;j<=m;j++){
if(c[j]=='#'){
s[j]++;
}
}
}
for(int i=1;i<=q;i++){
cin>>a[i];
a[i]++;
v[a[i]].push_back(i);
}
for(int i=1;i<=m;i++){
int l=max(1,i-2),r=i;
for(int j=l;j<=r;j++){
for(int x:v[j]){
if(!vis[x]&&s[i]>0){
s[i]--;
vis[x]=1;
ans[x][i-j+1]=1;
}
}
}
if(s[i]>0){
for(int j=l;j<=r;j++){
for(int x:v[j]){
int need=3-ans[x][i-j+1];
if(s[i]>=need){
s[i]-=need;
ans[x][i-j+1]=3;
}
else{
ans[x][i-j+1]+=s[i];
s[i]=0;
}
if(s[i]==0)break;
}
if(s[i]==0)break;
}
}
}
for(int i=1;i<=q;i++){
for(int j=1;j<=3;j++){
for(int k=1;k<=3;k++){
if(ans[i][k]>=j)cout<<'#';
else cout<<'.';
}
cout<<"\n";
}
}
}
}
using namespace sunburstfan;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
//FileIO();
int T=1;
while(T--){
solve();
}
return 0;
}
vjudge1