Submission #914518

# Submission time Handle Problem Language Result Execution time Memory
914518 2024-01-22T09:52:42 Z manizare Xylophone (JOI18_xylophone) C++14
100 / 100
60 ms 5292 KB
#include<bits/stdc++.h>
#include "xylophone.h"
#pragma GCC optimize("O3,unroll-loops")
#define pb push_back
#define F first
#define S second 
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define PII pair<pii , pii>
#define ld long double
#define sz(v) (int)v.size()
#define rep(i , a , b) for(int i=a;i <= (b);i++)
#define per(i , a , b) for(int i=a;i >= (b);i--)
using namespace std ;   
const int maxn = 1e6 + 10 , inf= 2e9 , mod = 1e9 + 7 , sq = 360 ,MX = 20000 ;
int p[maxn] , a[maxn] , d[maxn] , nd[maxn] ;


void solve(int n){
    rep(i , 1, n-1){
        d[i] = query(i , i+1) ;  
        nd[i] = d[i] ;  
    }
    rep(i , 1, n-2){
        if(d[i]+d[i+1]!=query(i ,i+2)){
            if(nd[i]>0)nd[i+1] = -d[i+1] ; 
        }else{
            if(nd[i]<0)nd[i+1] = -d[i+1] ;
        }
    }
    int mn= 0 ;
    p[1] =0 ;
    rep(i , 2, n){
        p[i] = p[i-1] + nd[i-1] ;
        mn = min(mn , p[i]) ;
    }
    rep(i , 1, n){
        p[i]+=-mn+1; 
    }
    rep(i , 1, n){
        if(p[i] == n){
            rep(i , 1, n){
                p[i] = n+1 - p[i] ;
            }
            break ;
        }
        if(p[i]==1)break ;
    }
    rep(i ,1 , n){
        answer(i , p[i]) ;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4544 KB Output is correct
2 Correct 1 ms 4800 KB Output is correct
3 Correct 1 ms 4548 KB Output is correct
4 Correct 2 ms 4544 KB Output is correct
5 Correct 2 ms 4540 KB Output is correct
6 Correct 1 ms 4540 KB Output is correct
7 Correct 1 ms 4544 KB Output is correct
8 Correct 2 ms 4548 KB Output is correct
9 Correct 1 ms 4544 KB Output is correct
10 Correct 2 ms 4800 KB Output is correct
11 Correct 2 ms 4548 KB Output is correct
12 Correct 2 ms 4540 KB Output is correct
13 Correct 2 ms 4544 KB Output is correct
14 Correct 2 ms 4800 KB Output is correct
15 Correct 2 ms 4548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4544 KB Output is correct
2 Correct 1 ms 4800 KB Output is correct
3 Correct 1 ms 4548 KB Output is correct
4 Correct 2 ms 4544 KB Output is correct
5 Correct 2 ms 4540 KB Output is correct
6 Correct 1 ms 4540 KB Output is correct
7 Correct 1 ms 4544 KB Output is correct
8 Correct 2 ms 4548 KB Output is correct
9 Correct 1 ms 4544 KB Output is correct
10 Correct 2 ms 4800 KB Output is correct
11 Correct 2 ms 4548 KB Output is correct
12 Correct 2 ms 4540 KB Output is correct
13 Correct 2 ms 4544 KB Output is correct
14 Correct 2 ms 4800 KB Output is correct
15 Correct 2 ms 4548 KB Output is correct
16 Correct 3 ms 4796 KB Output is correct
17 Correct 6 ms 4800 KB Output is correct
18 Correct 7 ms 4800 KB Output is correct
19 Correct 8 ms 4804 KB Output is correct
20 Correct 7 ms 4792 KB Output is correct
21 Correct 9 ms 4556 KB Output is correct
22 Correct 9 ms 4548 KB Output is correct
23 Correct 10 ms 4796 KB Output is correct
24 Correct 8 ms 5052 KB Output is correct
25 Correct 9 ms 4800 KB Output is correct
26 Correct 10 ms 4800 KB Output is correct
27 Correct 9 ms 4552 KB Output is correct
28 Correct 9 ms 4540 KB Output is correct
29 Correct 11 ms 4552 KB Output is correct
30 Correct 7 ms 4536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4544 KB Output is correct
2 Correct 1 ms 4800 KB Output is correct
3 Correct 1 ms 4548 KB Output is correct
4 Correct 2 ms 4544 KB Output is correct
5 Correct 2 ms 4540 KB Output is correct
6 Correct 1 ms 4540 KB Output is correct
7 Correct 1 ms 4544 KB Output is correct
8 Correct 2 ms 4548 KB Output is correct
9 Correct 1 ms 4544 KB Output is correct
10 Correct 2 ms 4800 KB Output is correct
11 Correct 2 ms 4548 KB Output is correct
12 Correct 2 ms 4540 KB Output is correct
13 Correct 2 ms 4544 KB Output is correct
14 Correct 2 ms 4800 KB Output is correct
15 Correct 2 ms 4548 KB Output is correct
16 Correct 3 ms 4796 KB Output is correct
17 Correct 6 ms 4800 KB Output is correct
18 Correct 7 ms 4800 KB Output is correct
19 Correct 8 ms 4804 KB Output is correct
20 Correct 7 ms 4792 KB Output is correct
21 Correct 9 ms 4556 KB Output is correct
22 Correct 9 ms 4548 KB Output is correct
23 Correct 10 ms 4796 KB Output is correct
24 Correct 8 ms 5052 KB Output is correct
25 Correct 9 ms 4800 KB Output is correct
26 Correct 10 ms 4800 KB Output is correct
27 Correct 9 ms 4552 KB Output is correct
28 Correct 9 ms 4540 KB Output is correct
29 Correct 11 ms 4552 KB Output is correct
30 Correct 7 ms 4536 KB Output is correct
31 Correct 23 ms 4532 KB Output is correct
32 Correct 30 ms 4532 KB Output is correct
33 Correct 58 ms 4540 KB Output is correct
34 Correct 58 ms 4544 KB Output is correct
35 Correct 53 ms 4580 KB Output is correct
36 Correct 46 ms 4804 KB Output is correct
37 Correct 48 ms 4796 KB Output is correct
38 Correct 56 ms 4544 KB Output is correct
39 Correct 49 ms 4548 KB Output is correct
40 Correct 45 ms 4796 KB Output is correct
41 Correct 43 ms 4796 KB Output is correct
42 Correct 48 ms 4796 KB Output is correct
43 Correct 51 ms 4804 KB Output is correct
44 Correct 44 ms 4560 KB Output is correct
45 Correct 45 ms 4796 KB Output is correct
46 Correct 38 ms 5068 KB Output is correct
47 Correct 48 ms 4544 KB Output is correct
48 Correct 50 ms 4796 KB Output is correct
49 Correct 47 ms 4800 KB Output is correct
50 Correct 44 ms 4800 KB Output is correct
51 Correct 46 ms 4540 KB Output is correct
52 Correct 48 ms 4788 KB Output is correct
53 Correct 41 ms 5048 KB Output is correct
54 Correct 48 ms 4796 KB Output is correct
55 Correct 44 ms 5292 KB Output is correct
56 Correct 53 ms 4796 KB Output is correct
57 Correct 60 ms 4560 KB Output is correct
58 Correct 48 ms 4800 KB Output is correct
59 Correct 44 ms 4548 KB Output is correct
60 Correct 51 ms 5292 KB Output is correct