結果
問題 |
No.1681 +-*
|
ユーザー |
|
提出日時 | 2025-04-12 21:12:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,143 bytes |
コンパイル時間 | 2,023 ms |
コンパイル使用メモリ | 198,024 KB |
実行使用メモリ | 16,068 KB |
最終ジャッジ日時 | 2025-04-12 21:12:08 |
合計ジャッジ時間 | 6,062 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | TLE * 1 -- * 17 |
コンパイルメッセージ
main.cpp: In function ‘ll cal(int, ll, ll)’: main.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type] 17 | } | ^
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; const int N=1e5+5; const int mod=1e9+7; ll ans=0; int n; int op[N], a[N]; ll cal(int x,ll a,ll b){ if(x==0){ return (a^b)%mod; }else if(x==1){ return (a+b)%mod; }else if(x==2){ return (a-b)%mod; } } void dfs(int x){ if(x==n){ ll s=0; vector<ll> st; vector<int> opst; st.push_back(a[0]); for(int i=1;i<n;i++){ if(op[i]==0){ ll p=cal(0,st.back(),a[i]); st.pop_back(); st.push_back(p); }else{ st.push_back(a[i]); opst.push_back(op[i]); } } if(st.size()==1) s=st.back(); for(int i=1;i<st.size();i++){ s+=cal(opst[i-1],st[i-1],st[i]); st[i]=cal(opst[i-1],st[i-1],st[i]); } ans+=s; ans%=mod; return; } for(int i=0;i<3;i++){ op[x]=i; dfs(x+1); } } int main(){ cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } dfs(1); cout<<ans; return 0; }