# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
203194 |
2020-02-19T19:04:54 Z |
MKopchev |
Sticks (POI11_pat) |
C++14 |
|
406 ms |
45772 KB |
#include<bits/stdc++.h>
using namespace std;
const int nmax=1e6+42,inf=2e9+42;
int k;
pair<int/*length*/,int/*colour*/> inp[nmax];
int pointer;
vector<int> seen[nmax];
int last_seen[nmax];
bool is_less(pair<int/*length*/,int/*colour*/> a,pair<int/*length*/,int/*colour*/> b)
{
return a.first<b.first;
}
int furthest(int colour,int up_to)
{
int ok=0,not_ok=seen[colour].size();
while(not_ok-ok>1)
{
int av=(ok+not_ok)/2;
if(seen[colour][av]<=up_to)ok=av;
else not_ok=av;
}
return seen[colour][ok];
}
int main()
{
scanf("%i",&k);
int SZ,current;
for(int i=1;i<=k;i++)
{
scanf("%i",&SZ);
for(int j=1;j<=SZ;j++)
{
scanf("%i",¤t);
seen[i].push_back(current);
pointer++;
inp[pointer]={current,i};
}
sort(seen[i].begin(),seen[i].end());
}
for(int i=1;i<=k;i++)last_seen[i]=inf;
sort(inp+1,inp+pointer+1);
for(int i=pointer;i>=1;i--)
{
pair<int/*length*/,int/*colour*/> best={inf,0},second_best={inf,0},current;
for(int j=1;j<=k;j++)
if(j!=inp[i].second)
{
current={last_seen[j],j};
if(is_less(current,best))second_best=best,best=current;
else if(is_less(current,second_best))second_best=current;
}
if(second_best.first<inf)
{
best.first=furthest(best.second,second_best.first);
if(inp[i].first+best.first>second_best.first)
{
printf("%i %i %i %i %i %i\n",inp[i].second,inp[i].first,best.second,best.first,second_best.second,second_best.first);
return 0;
}
}
last_seen[inp[i].second]=inp[i].first;
}
printf("NIE\n");
return 0;
}
Compilation message
pat.cpp: In function 'int main()':
pat.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i",&k);
~~~~~^~~~~~~~~
pat.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i",&SZ);
~~~~~^~~~~~~~~~
pat.cpp:39:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i",¤t);
~~~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
23804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
23800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
23800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
23800 KB |
Output is correct |
2 |
Correct |
20 ms |
23928 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
23800 KB |
Oczekiwano NIE |
2 |
Correct |
34 ms |
24568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
23928 KB |
Oczekiwano NIE |
2 |
Correct |
36 ms |
24696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
23928 KB |
Oczekiwano NIE |
2 |
Correct |
61 ms |
26104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
24312 KB |
Oczekiwano NIE |
2 |
Correct |
83 ms |
27192 KB |
Output is correct |
3 |
Correct |
61 ms |
26104 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
25336 KB |
Oczekiwano NIE |
2 |
Correct |
128 ms |
29364 KB |
Output is correct |
3 |
Correct |
91 ms |
27012 KB |
Oczekiwano NIE |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
220 ms |
34924 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
207 ms |
34776 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
406 ms |
45772 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
401 ms |
45668 KB |
Memory limit exceeded (if you are sure your verdict is not MLE, please contact us) |
2 |
Halted |
0 ms |
0 KB |
- |