Submission #1250860

#TimeUsernameProblemLanguageResultExecution timeMemory
1250860haiphong5g0Triple Peaks (IOI25_triples)C++20
34.29 / 100
935 ms1864 KiB
//#include "triplepeaks.h" #include <bits/stdc++.h> #define task "TEST" #define task2 "A" #define pl pair<ll, ll> #define pf push_front #define pb push_back #define pob pop_back #define pof pop_front #define mp make_pair #define fi first #define se second #define FOR(i, a, b, c) for (int i=a; i<=b; i+=c) #define FORE(i, a, b, c) for (int i=a; i>=b; i+=c) using namespace std; using ll = long long; using ull = unsigned long long; const int Mod = 998244353; const int maxn = 1e3; const ll Inf = 1e16; int n; ll Check(ll i, ll j, ll k, vector<int>& H) { if (i < 0 or k >= n) return 0; multiset<int> a, b; a.insert({k-i, j-i, k-j}); b.insert({H[i], H[j], H[k]}); //if (a == b) cerr << i << " " << j << " " << k << '\n'; return (a == b); } ll doubles(ll i, ll j, vector<int>& H) { ll v = abs(j-i); ll ans = 0; ans += Check(i, j, H[i] + i, H); ans += Check(i, j, H[i] + j, H); if (H[j] != H[i] and H[i] + j != H[j] + i) ans += Check(i, j, H[j] + i, H); if (H[j] != H[i] and H[i] + i != H[j] + j) ans += Check(i, j, H[j] + j, H); return ans; } ll count_triples(vector<int> H) { n = H.size(); ll cnt = 0; if (n <= 2000) { FOR(i, 0, n-3, 1) FOR(j, i+1, n-2, 1) cnt += doubles(i, j, H); } else { FOR(k, 1, n, 1) { ll i = k - H[k]; if (i < 0 or i >= n) continue; if (i + H[i] == k - H[i]) cnt += Check(i, i+H[i], k, H); else cnt += Check(i, i+H[i], k, H) + Check(i, k-H[i], k, H); } } return cnt; } vector<int> construct_range(int M, int K) { vector<int> a; a.clear(); FOR(i, 0, M-1, 1) { if (i % 3 == 0) a.pb(2); else a.pb(1); } return a; }

Compilation message (stderr)

triples.cpp: In function 'll Check(ll, ll, ll, std::vector<int>&)':
triples.cpp:25:16: warning: narrowing conversion of '(k - i)' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   25 |     a.insert({k-i, j-i, k-j});
      |               ~^~
triples.cpp:25:16: warning: narrowing conversion of '(k - i)' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
triples.cpp:25:21: warning: narrowing conversion of '(j - i)' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   25 |     a.insert({k-i, j-i, k-j});
      |                    ~^~
triples.cpp:25:21: warning: narrowing conversion of '(j - i)' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
triples.cpp:25:26: warning: narrowing conversion of '(k - j)' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   25 |     a.insert({k-i, j-i, k-j});
      |                         ~^~
triples.cpp:25:26: warning: narrowing conversion of '(k - j)' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...