Submission #1279348

#TimeUsernameProblemLanguageResultExecution timeMemory
1279348longlong5a6Fortune Telling 2 (JOI14_fortune_telling2)C++20
4 / 100
3094 ms1236 KiB
//longlong5a6 #include <bits/stdc++.h> #define pii pair<int,int> #define F first #define S second #define bit(i, x)((x >> i) & 1) #define sobit(i) __builtin_popcount((int)(i)) #define sobitll(i) __builtin_popcountll((int)(i)) #define pb push_back #define all(x) x.begin(),x.end() #define vi vector<int> #define For(i,x,n) for(int (i)=(int)(x);(i)<=(int)(n);(i)++) #define round(m,n) setprecision((int)m) << fixed << double(n) #define down "\n" #define TASK "domino" #define int long long #define maxn 200001 using namespace std; int n,k; pii a[maxn]; int t[maxn]; int global; pii calc(int l,int r) { if (l==r) { int res1,res2; res1=0; res2=1; if (t[l]>=a[global].F) res1=1; if (t[l]>=a[global].S) res2=0; return {res1,res2}; } int mid=(r+l)/2; pii left=calc(l,mid); pii right=calc(mid+1,r); int res1,res2; res1=res2=0; if (left.F&1) { res1=right.S; } else { res1=right.F; } if (left.S&1) { res2=right.S; } else { res2=right.F; } return {res1,res2}; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("in.txt","r")) { freopen("in.txt","r",stdin); } if (fopen(TASK".INP","r")) { freopen(TASK".INP","r",stdin); freopen(TASK".OUT","w",stdout); } cin>>n>>k; For(i,1,n) { cin>>a[i].F>>a[i].S; } For(i,1,k) { cin>>t[i]; } int res=0; For(i,1,n) { global=i; pii g=calc(1,k); if (g.F&1) res+=a[i].S; else res+=a[i].F; } cout<<res; }

Compilation message (stderr)

fortune_telling2.cpp: In function 'int main()':
fortune_telling2.cpp:65:20: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |             freopen("in.txt","r",stdin);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~
fortune_telling2.cpp:70:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |                 freopen(TASK".INP","r",stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
fortune_telling2.cpp:71:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |                 freopen(TASK".OUT","w",stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...