Submission #586164

# Submission time Handle Problem Language Result Execution time Memory
586164 2022-06-30T03:10:45 Z 21ti_dpkhang Skyscraper (JOI16_skyscraper) C++17
5 / 100
238 ms 324 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FORU(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define str string
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ED cout<<endl;
const ll N=1000005;
const ll MOD=1e9+7;
ll  n, kq[11], dd[10],a[1005],k,d;
void fre()
{
    freopen("exc.inp","r",stdin);
    freopen("exc.out","w",stdout);
}
void xuat()
{
    ll s=0;
    for (int j=2; j<=n; j++)
        {//cout<< kq[j]<<" ";
        s=(s+abs(kq[j]-kq[j-1]))%MOD;}
    //cout <<s<< endl;
    if(s<=k)
    {
        d++;
    }
}

void hoanvi(int i)
{
    if (i>n) xuat();
    for (int j=1; j<=n; j++)
        {
            if(dd[j]==0){
                    dd[j]=1;
            kq[i]=a[j];
            hoanvi(i+1);
            dd[j]=0;
            }
        }
}
void solve()
{
    cin >> n >> k;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
        dd[i]=0;
    }
    hoanvi(1);
    cout<<d;
}
int main()
{
    //fre();
    fast
    solve();
}

Compilation message

skyscraper.cpp: In function 'void fre()':
skyscraper.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen("exc.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen("exc.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 3 ms 320 KB Output is correct
6 Correct 3 ms 320 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 3 ms 324 KB Output is correct
9 Correct 3 ms 212 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 238 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 3 ms 320 KB Output is correct
6 Correct 3 ms 320 KB Output is correct
7 Correct 3 ms 212 KB Output is correct
8 Correct 3 ms 324 KB Output is correct
9 Correct 3 ms 212 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Incorrect 238 ms 312 KB Output isn't correct
12 Halted 0 ms 0 KB -