답안 #1010988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1010988 2024-06-29T16:22:34 Z cpdreamer Fancy Fence (CEOI20_fancyfence) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <utility>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;
const int max_n=INT_MAX;
const int inf=1e8;
typedef long long  ll;
#define LLM LONG_LONG_MAX
#define pb push_back
#define F first
#define P pair
#define all(v) v.begin(),v.end()
#define V vector
#define S second
const long long MOD = 1e9+7; // 1e9 + 7

void file(){
    freopen("input.txt.txt","r",stdin);
    freopen("output.txt.txt","w",stdout);
}
void setio(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
bool check(V<P<int,int>>&vp,int r1,int r2,int l){
    for(int i=r1;i<=r2;i++){
        if(min(vp[i].F,vp[i].S)<l)
            return false;
    }
    return true;
}
void solve() {
    int n;
    cin>>n;
    int A[n];
    int B[n];
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=0;i<n;i++){
        cin>>B[i];
    }
    ll s=0;
    ll c=0;
    ll current=0;
    V<ll>vp;
    bool flag=false;
    for(int i=0;i<n;i++) {
        if (A[i] == 1) {
            if (flag) {
                vp.pb(current);
            }
            current = 0;
            flag = false;
        }
        else{
            flag=true;
            current+=B[i];
        }
        s+=B[i];
    }
    if(flag)
        vp.pb(current);
    ll a;
    if(s%2==0){
        a=s/2;
        a=a%MOD;
        a=(a*(s+1))%MOD;
    }
    else{
        a=(s+1)/2;
        a=a%MOD;
        a=(a*s)%MOD;
    }
    c=(c+a)%MOD;
    for(auto u:vp){
        ll b=u;
        b=b%MOD;
        b=(b*(u+1))%MOD;
        c=(c+b)%MOD;
    }
    cout<<c<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //file();
    solve();
    return 0;
}

Compilation message

fancyfence.cpp: In function 'void file()':
fancyfence.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen("input.txt.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
fancyfence.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen("output.txt.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fancyfence.cpp: In function 'void setio(std::string)':
fancyfence.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fancyfence.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -