Submission #1031427

# Submission time Handle Problem Language Result Execution time Memory
1031427 2024-07-22T20:26:45 Z 7again Timovi (COCI18_timovi) C++17
20 / 80
624 ms 3160 KB
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define in insert
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define FAST ios::sync_with_stdio(0);cout.tie(0);cin.tie(0)

using namespace std ;

void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}

const int N = 300000 , MOD = 1e9+7 ;

//bool inside(int x,int y){return(x<n&&y<m&&x>-1&&y>-1&&a[x][y]!='#');}

//int dx[4]{1 , -1 , 0 , 0} , dy[4]{0 , 0 , 1 , -1} ;


void slv()
{
    int n , m , k ;
    cin >> n >> m >> k ;

    if(k / m < n)
    {
        for(int i = 0 ; i < k / m ; i++)
            cout << m << " " ;
        cout << k % m << " " ;
        for(int i = k / m + 1 ; i < n ; i++)
            cout << 0 << " " ;
        return ;
    }

    int pfx[n + 1] ;
    fill(pfx , pfx + n + 1 , 0) ;
    pfx[0] += m ;
    pfx[n] -= m ;
    k -= (n * m) ;

    bool ok = false ;
    while(k)
    {
        if(ok)
        {
            if(k >= n - 1)
            {
                pfx[1]++ ;
                k -= n - 1 ;
            }
            else
            {
                pfx[1]++ ;
                pfx[k + 1]-- ;
                k = 0 ;
            }
            ok = false ;
        }
        else
        {
            if(k >= n - 1)
            {
                pfx[n - 2]++ ;
                k -= n - 1 ;
            }
            else
            {
                pfx[n - 1]-- ;
                pfx[n - k - 1]++ ;
                k = 0 ;
            }
            ok = true ;
        }
    }

    for(int i = 1 ; i < n ; i++)
        pfx[i] += pfx[i - 1] ;

    for(int i = 0 ; i < n ; i++)
        cout << pfx[i] << " " ;
}
main()
{
    //setIO("lasers") ;

    FAST ;

    int t = 1 ;
    //cin >> t ;

    while(t--)
        slv() ;
}

Compilation message

timovi.cpp:87:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   87 | main()
      | ^~~~
timovi.cpp: In function 'void setIO(std::string)':
timovi.cpp:16:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
timovi.cpp:16:66: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Correct 11 ms 780 KB Output is correct
4 Correct 8 ms 604 KB Output is correct
5 Incorrect 110 ms 428 KB Output isn't correct
6 Incorrect 624 ms 348 KB Output isn't correct
7 Incorrect 10 ms 3160 KB Output isn't correct
8 Incorrect 11 ms 2908 KB Output isn't correct