제출 #362207

#제출 시각아이디문제언어결과실행 시간메모리
362207knightron0Paint By Numbers (IOI16_paint)C++17
10 / 100
214 ms492 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fr first #define sc second #define clr(a, x) memset(a, x, sizeof(a)) #define dbg(x) cout<<"("<<#x<<"): "<<x<<endl; #define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl; #define all(v) v.begin(), v.end() #define lcm(a, b) (a * b)/__gcd(a, b) #define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl; #define endl '\n' #define float long double const int MOD = 1e9 + 7; const int INF = 2e15; const int MAXN = 1e5 + 5; string solve_puzzle(string s, vector<int> c){ int n = s.length(); int tot = 0; int freq_empty[n+2]; clr(freq_empty, 0); int freq_used[n+2]; clr(freq_used, 0); for(int mask = 0;mask<(1<<n);mask++){ bool valid = true; vector<int> blocks; int curr = 0; for(int b=0;b<n;b++){ if(mask & (1<<b)){ if(s[b] == '_'){ valid = false; break; } else { curr++; continue; } } else { if(s[b] == 'X'){ valid = false; break; } else { if(curr!=0){ blocks.pb(curr); } curr = 0; } } } if(curr!=0){ blocks.pb(curr); } if(blocks.size() != c.size()) valid = false; if(!valid) continue; for(int i= 0;i<c.size();i++){ if(c[i] != blocks[i]) { valid = 0; break; } } if(valid){ tot++; for(int b=0;b<n;b++){ if(mask & (1<<b)){ freq_used[b]++; } else { freq_empty[b]++; } } } } string res = ""; for(int b=0;b<n;b++){ if(freq_empty[b] == tot){ res += "_"; } else if(freq_used[b] == tot){ res += "X"; } else { res += "?"; } } return res; }

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

paint.cpp:17:17: warning: overflow in conversion from 'double' to 'int' changes value from '2.0e+15' to '2147483647' [-Woverflow]
   17 | const int INF = 2e15;
      |                 ^~~~
paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:57:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   for(int i= 0;i<c.size();i++){
      |                ~^~~~~~~~~
#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...