답안 #827405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
827405 2023-08-16T12:48:26 Z vjudge1 Zalmoxis (BOI18_zalmoxis) C++17
5 / 100
97 ms 10364 KB
/*


*/

#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();

}


/*

*/

Compilation message

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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 90 ms 10300 KB not a zalsequence
2 Incorrect 94 ms 10356 KB not a zalsequence
3 Correct 94 ms 10304 KB Output is correct
4 Incorrect 96 ms 10264 KB not a zalsequence
5 Incorrect 91 ms 10268 KB not a zalsequence
6 Incorrect 93 ms 10300 KB not a zalsequence
# 결과 실행 시간 메모리 Grader output
1 Incorrect 90 ms 10256 KB Unexpected end of file - int32 expected
2 Incorrect 90 ms 10364 KB Unexpected end of file - int32 expected
3 Incorrect 91 ms 10308 KB Unexpected end of file - int32 expected
4 Incorrect 89 ms 10364 KB Unexpected end of file - int32 expected
5 Incorrect 89 ms 10356 KB Unexpected end of file - int32 expected
6 Incorrect 88 ms 10316 KB Unexpected end of file - int32 expected
7 Incorrect 88 ms 10300 KB Unexpected end of file - int32 expected
8 Incorrect 97 ms 10364 KB Unexpected end of file - int32 expected
9 Incorrect 74 ms 8304 KB Unexpected end of file - int32 expected
10 Incorrect 29 ms 3676 KB Unexpected end of file - int32 expected
11 Incorrect 46 ms 5348 KB Unexpected end of file - int32 expected
12 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
13 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
14 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected