제출 #889586

#제출 시각아이디문제언어결과실행 시간메모리
889586UmairAhmadMirzaPaint By Numbers (IOI16_paint)C++17
32 / 100
1 ms604 KiB
#pragma once #include<bits/stdc++.h> using namespace std; int k=0; string s; vector<int> c; int n; bool check(int l,int r,int sz){ int sm=0; for (int i = l; i <=r; ++i) sm+=c[i]; int ln=(r-l)+1; sm+=ln-1; if(sm<=sz) return 1; return 0; } string solve_puzzle(string ss, vector<int> cc){ k=cc.size(); c=cc; s=ss; n=s.length(); for (int i = 0; i < n; ++i) { //if i put a _ here then check that is there a valid solution s[i]='X'; for (int j = -1; j < k; ++j) if(check(0,j,i) && check( j+1,k-1,n-(i+1)) ){ s[i]='?'; break; } } int tot=0; for (int i = 0; i < k; ++i) tot+=c[i]; for (int i = 0; i < n; ++i) { if(s[i]=='X') continue; int sm=0; s[i]='_'; for (int j = 0; j < k; ++j) { for (int f = max(0,(i-c[j])+1); f <=i; ++f) { int smm=sm+j; if(smm>=f+1) continue; smm=tot-sm; smm+=k-(j+1); if(smm<=n-f){ s[i]='?'; break; } } if(s[i]=='?') break; sm+=c[j]; } } return s; }

컴파일 시 표준 에러 (stderr) 메시지

paint.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...