답안 #1041440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041440 2024-08-02T04:00:16 Z vjudge1 Segway (COI19_segway) C++17
40 / 100
3 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

void solve(){
    ll n , m , k , a , mx = 0;
    cin >> n;
    int ls[n + 1][4];
    for(int i =1 ;i <= n ;i ++){
        for(int j = 0; j< 3; j++){
            cin >> ls[i][j];
        }
    }
    vector<ll> pre(10000) , acc(310) , ans(310) , pos(310) , sped(310);
    cin >> m;
    for(int i =0 ;i < m ;i ++){
        cin >> a;
        acc[a] = 1;
    }
    for(int i = 0 ;i< 100; i ++){
        for(int  j =0 ; j< 10000; j ++){
            pre[j] = 0;
        }
        for(int j = 1; j <=n ; j++){
            pre[ans[j]] += 1;
        }
        for(int  j =1 ; j < 10000; j ++){
            pre[j] += pre[j - 1];
        }
        for (int j = 1; j <= n; j++){
            if (sped[j] and pos[j] < 300){
                pos[j] += 1;
                ans[j] += 1;
                sped[j] -= 1;
            }
            else if (pos[j] < 300){
                ll val = 0;
                if(ans[j] - 1 >= 0){
                    val = pre[ans[j] - 1] % 20;
                }
                if (acc[i]){
                    sped[j] = val;
                }
                if (sped[j]){
                    sped[j] -= 1;
                    pos[j] += 1;
                    ans[j] += 1;
                }
                else{
                    ans[j] += ls[j][0];
                }
            }
        }
    }
    for(int i = 100 ;i< 200; i ++){
        for(int  j =0 ; j< 10000; j ++){
            pre[j] = 0;
        }
        for(int j = 1; j <=n ; j++){
            pre[ans[j]] += 1;
        }
        for(int  j =1 ; j < 10000; j ++){
            pre[j] += pre[j - 1];
        }
        for (int j = 1; j <= n; j++){
            if (sped[j] and pos[j] < 300){
                pos[j] += 1;
                ans[j] += 1;
                sped[j] -= 1;
            }
            else if (pos[j] < 300){
                ll val = 0;
                if(ans[j] - 1 >= 0){
                    val = pre[ans[j] - 1] % 20;
                }
                if (acc[i]){
                    sped[j] = val;
                }
                if (sped[j]){
                    sped[j] -= 1;
                    pos[j] += 1;
                    ans[j] += 1;
                }
                else{
                    ans[j] += ls[j][1];
                }
            }
        }
    }
    for(int i = 200 ;i< 300; i ++){
        for(int  j =0 ; j< 10000; j ++){
            pre[j] = 0;
        }
        for(int j = 1; j <=n ; j++){
            pre[ans[j]] += 1;
        }
        for(int  j =1 ; j < 10000; j ++){
            pre[j] += pre[j - 1];
        }
        for (int j = 1; j <= n; j++){
            if (sped[j] and pos[j] < 300){
                pos[j] += 1;
                ans[j] += 1;
                sped[j] -= 1;
            }
            else if (pos[j] < 300){
                ll val = 0;
                if(ans[j] - 1 >= 0){
                    val = pre[ans[j] - 1] % 20;
                }
                if (acc[i]){
                    sped[j] = val;
                }
                if (sped[j]){
                    sped[j] -= 1;
                    pos[j] += 1;
                    ans[j] += 1;
                }
                else{
                    ans[j] += ls[j][2];
                }
            }
        }
    }
    for(int i = 1; i<= n ;i ++){
        cout << ans[i] << '\n';
    }

}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tests = 1;
    // cin >> tests;
    for (int i = 1; i <= tests; i++){
        solve();
    }
    return 0;
}

Compilation message

segway.cpp: In function 'void solve()':
segway.cpp:7:16: warning: unused variable 'k' [-Wunused-variable]
    7 |     ll n , m , k , a , mx = 0;
      |                ^
segway.cpp:7:24: warning: unused variable 'mx' [-Wunused-variable]
    7 |     ll n , m , k , a , mx = 0;
      |                        ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Incorrect 2 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Incorrect 2 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -