제출 #827405

#제출 시각아이디문제언어결과실행 시간메모리
827405vjudge1Zalmoxis (BOI18_zalmoxis)C++17
5 / 100
97 ms10364 KiB
/* */ #include<iostream> #include<vector> #include<iomanip> #include<algorithm> #include<map> #include<set> #include<climits> #include<numeric> #include<queue> #include<unordered_map> #include<string> #include<climits> #include<unordered_set> #include<bitset> #include<cstring> #include<cmath> #include<stack> #include<tuple> #if 1 #define pb push_back #define endl '\n' #define fio ios_base::sync_with_stdio(false);cin.tie(NULL); #define CDIV(a,b) (((a)+(b)-(1))/(b)) using namespace std; typedef long long lint; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<vi> vivi; typedef pair<char,int> pci; typedef vector<bool> vb; typedef long double ld; const int inf = 1e17 + 5; const int mod = 1e9 + 7; const int N = 1e6; #endif void fileio(string s = "test"){ #ifndef ONLINE_JUDGE freopen((s+string(".in")).c_str(),"r",stdin); freopen((s+string(".out")).c_str(),"w",stdout); #endif } int mod_(int a, int b) { if(a >= 0)return a % b; a += (-a/b + 1) * b; return a % b; } /* 1. CHECK IF THE ANSWER IS MODULO M DAMMIT 2. Edge cases 3. Check for overflow (maybe before edge cases idk) 24. Use the number 24 (it automatically makes everything turn to ac) */ void solve(){ int n, k; cin >> n >> k; vi v(n); for(int& i : v)cin >> i; if(n == 1) { cout << v[0] << ' ' << v[0] << endl; return; } int mn = *min_element(v.begin(), v.end()); int need = v.back(); bool first = true; vi ans; for(int i = n - 1; i >= 0; --i) { if(v[i] == mn ) { if(first) { first = false; need = mn; ans.pb(v[i]); continue; } else { first = true; need = v[i] + 1; } } if(v[i] != need) { //cout << i << ' ' << need << endl; ans.push_back(v[i]); ans.push_back(need); for(int j = i - 1; j >= 0; --j)ans.push_back(v[j]); break; } else { ans.pb(v[i]); need = v[i] + 1; } } reverse(ans.begin(), ans.end()); for(int& i : ans)cout << i << ' ';cout << endl; } signed main(){ fio; //int t;cin >> t;while(t--) solve(); } /* */

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

zalmoxis.cpp:37:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+17' to '2147483647' [-Woverflow]
   37 | const int inf = 1e17 + 5;
      |                 ~~~~~^~~
zalmoxis.cpp: In function 'void solve()':
zalmoxis.cpp:114:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  114 |     for(int& i : ans)cout << i << ' ';cout << endl;
      |     ^~~
zalmoxis.cpp:114:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  114 |     for(int& i : ans)cout << i << ' ';cout << endl;
      |                                       ^~~~
zalmoxis.cpp: In function 'void fileio(std::string)':
zalmoxis.cpp:44:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         freopen((s+string(".in")).c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
zalmoxis.cpp:45:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |         freopen((s+string(".out")).c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...