제출 #1292955

#제출 시각아이디문제언어결과실행 시간메모리
1292955binminh01Watermelon (INOI20_watermelon)C++20
0 / 100
2093 ms1608 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int mn = 1e5 + 5; ll n, a[mn], k, b[mn], s[mn]; void solve(){ cin >> n >> k; for(int i = 1; i <= n; ++i) a[i] = i, cin >> s[i]; do { for(int i = n; i >= 1; --i){ b[i] = -1; ll pot = 1; for(int j = i + 1; j <= n; ++j){ if(a[j] > a[i] && (b[j] == -1 || pot <= b[j])){ b[i] = pot; break; } if(b[j] == -1) break; pot = max(pot, b[j] + 1); } } ll c = 1; for(int i = 1; i <= n; ++i){ c &= (b[i] == s[i]); } k -= c; // for(int i = 1) if(k == 0){ for(int i = 1; i <= n; ++i) cout << a[i] << " "; return; } } while (next_permutation(a + 1, a + n + 1)); cout << -1; return; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); if(fopen(".INP", "r")) { freopen(".INP", "r", stdin); freopen(".OUT", "w", stdout); } int testCase = 1; //cin >> testCase; while(testCase--) solve(); }

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

Main.cpp: In function 'int main()':
Main.cpp:43:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         freopen(".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.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(".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...