11804 - Argentina
Moderator: Board moderators
-
- New poster
- Posts: 9
- Joined: Sat Sep 11, 2010 1:21 am
- Location: Rio de Janeiro - Brasil
Can i use system("pause")?
I was using system("pause") in my code with the library stdlib.h and i was getting wrong answer on the problem 11677 - Alarm Clock. I was alerted not to use the system("pause"), so i remove it and the library, but i'm still getting wrong answer. All of my outputs is certain. I tested my code with command using a .in file with many examples and it's ok. It's my third problem that is ok and i give wrong answer.
Computer Science - UERJ - Rio de Janeiro - Brasil.
Re: Can i use system("pause")?
How are you sure that you have tried with all types of cases?ItaloSpedini wrote:I tested my code with command using a .in file with many examples and it's ok.
-
- New poster
- Posts: 9
- Joined: Sat Sep 11, 2010 1:21 am
- Location: Rio de Janeiro - Brasil
Re: Can i use system("pause")?
I didn't said that i tried with all types of case, but i tried with many different cases (some of them i got on the forum, in the question topic), even with the "0 0 0 0" in the first line, and i'm still getting wrong answer.sohel wrote:How are you sure that you have tried with all types of cases?ItaloSpedini wrote:I tested my code with command using a .in file with many examples and it's ok.
EDIT: Oh, now i saw that your name is in the problem 11804 - Argentina as the problem setter, can I send you a PM about this problem? I think it was correct, and i received wrong answer too.
Thanks,
Ítalo.
Computer Science - UERJ - Rio de Janeiro - Brasil.
Re: Can i use system("pause")?
Im getting WA but dont know why, please help me....
Code: Select all
/*in the name of Allah */
# include <list>
# include <deque>
# include <bitset>
# include <algorithm>
# include <functional>
# include <numeric>
# include <utility>
# include <sstream>
# include <iostream>
# include <iomanip>
# include <cstdio>
# include <cmath>
# include <cstdlib>
# include <ctime>
# include <set>
# include <map>
# include <cmath>
# include <queue>
# include <limits>
# include <stack>
# include <vector>
# include <cstring>
# include <cstdio>
using namespace std;
# define MEM(array,w) memset(array,w,sizeof array)
# define fr(i,a,b) for(int (i) = a ; i < b ; i++)
# define SET set<int>::iterator it = s.begin(); it != s.end();it++
# define ULL unsigned long long
# define eps 1e-9
# define SS stringstream
# define PR pair<int , int>
# define all(c) (c).begin(), (c).end()
# define maxint 1 << 31 - 1
# define FOR(i, a, b) for (int i=a; i<b; i++)
# define REP(i, a) FOR(i, 0, a)
# define rive(s) reverse(s.begin(),s.end())
# define OK(R,C) if(i>=0 && j>=0 && j<=C && i<=R)
template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}
int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
bool isprime(int n){if( n<2) return 0;for( int i=2; i*i<=n ; i++)if(n%i==0)return 0; return 1;return 0;}
int pel(string s){string t;t=s;reverse(t.begin(),t.end());if(s==t)return 1;return 0;}
struct ball
{
string pl;
int att,def;
}arg[11];
int main()
{
int ca=0;
int t;
cin>>t;
while(t--)
{
string s;
int a[11],d[11];
for(int i=0;i<10;i++)
{
cin>>arg[i].pl>>arg[i].att>>arg[i].def;
}
for(int i=0;i<10;i++)
{
for(int j=i+1;j<10;j++)
{
if(arg[i].att<arg[j].att)swap(arg[i],arg[j]);
else if(arg[i].att==arg[j].att)if(arg[i].def>arg[j].def)swap(arg[i],arg[j]);
else {if(arg[i].pl>arg[j].pl)swap(arg[i],arg[j]);}
}
}
vector<string>fir,sec;
for(int i=0;i<10;i++){if(i<5)fir.push_back(arg[i].pl);else sec.push_back(arg[i].pl);}
sort(all(fir));sort(all(sec));
cout<<"Case "<<++ca<<":"<<endl;
cout<<"(";
for(int i=0;i<5;i++)
{
cout<<fir[i];if(i<4)cout<<", ";
}
cout<<")"<<endl;
cout<<"(";
for(int i=0;i<5;i++)
{
cout<<sec[i];if(i<4)cout<<", ";
}
cout<<")"<<endl;
}
return 0;
}
"Try and Try"
-
- New poster
- Posts: 31
- Joined: Thu Nov 24, 2011 12:08 am
11804 - Argentina
can this problem be solved by sorting?
my algorithm is:
** first sort the attacking ability in descending order.
** if two player'r attacking ability is same, the player having less defending ability will come first.
now the first five players are for attacking and the last five are for defending.
is this algorithm correct for this problem?
i'm getting WA with this algorithm.
my algorithm is:
** first sort the attacking ability in descending order.
** if two player'r attacking ability is same, the player having less defending ability will come first.
now the first five players are for attacking and the last five are for defending.
is this algorithm correct for this problem?
i'm getting WA with this algorithm.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11804 - Argentina
Yes that matches the problem description, and how you need to sort on this problem. Did you also code: If there is still more than one combination, pick the attackers that come lexicographically earliest.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 31
- Joined: Thu Nov 24, 2011 12:08 am
Re: 11804 - Argentina
right! got AC using this algo.
Re: 11804 - Argentina
I m getting WA. PLz Help

Code: Select all
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;
struct playerInfo
{
char name[50];
int attackingAbility;
int defendingAbility;
};
bool comparebyAttack(const playerInfo &a,const playerInfo &b)
{
if(a.attackingAbility==b.attackingAbility)
{
if(a.defendingAbility == b.defendingAbility) return strcmp(a.name,b.name)<0;
return a.defendingAbility < b.defendingAbility;
}
return a.attackingAbility>b.attackingAbility;
}
bool ComparebyName(const playerInfo &a,const playerInfo &b)
{
return strcmp(a.name,b.name)<0 ;
}
int main()
{
int t,c=1;
cin>>t;
while(t--)
{
vector<playerInfo> player;
playerInfo temp;
for(int i=0;i<10;i++)
{
cin>>temp.name>>temp.attackingAbility>>temp.defendingAbility;
player.push_back(temp);
}
sort(player.begin(),player.end(),comparebyAttack);
sort(player.begin(),player.begin()+5,ComparebyName);
sort(player.begin()+6,player.end(),ComparebyName);
printf("Case %d:\n",c++);
printf("(%s, %s, %s, %s, %s)\n",player[0].name,player[1].name,player[2].name,player[3].name,player[4].name);
printf("(%s, %s, %s, %s, %s)\n",player[5].name,player[6].name,player[7].name,player[8].name,player[9].name);
player.clear();
}
return 0;
}
Re: 11804 - Argentina
You may try the following cases:Nut_Boltu wrote:I m getting WA. PLz Help![]()
Input
Code: Select all
4
racsts 66 31
stratb 69 11
sresbs 65 1
siebar 0 39
strrrc 79 89
cssits 14 56
strbri 58 28
rebeat 80 11
ursoca 51 52
oibeoe 99 83
tr 89 52
s 33 78
u 68 24
erc 90 63
ocbcs 52 17
cttt 86 15
eurco 94 2
rri 19 14
orsabc 72 8
buou 23 21
sortr 20 92
uoase 16 16
ub 16 82
rasbce 2 99
cacua 6 16
rac 50 79
rbibo 21 27
esbtb 98 71
itc 19 83
rso 26 99
a 39 47
b 27 40
c 0 6
d 89 28
e 22 57
f 71 20
g 98 31
h 77 14
i 80 99
j 94 83
Code: Select all
Case 1:
(oibeoe, racsts, rebeat, stratb, strrrc)
(cssits, siebar, sresbs, strbri, ursoca)
Case 2:
(cttt, erc, eurco, orsabc, tr)
(buou, ocbcs, rri, s, u)
Case 3:
(esbtb, rac, rbibo, rso, sortr)
(cacua, itc, rasbce, ub, uoase)
Case 4:
(d, g, h, i, j)
(a, b, c, e, f)
Re: 11804 - Argentina
Thanks. Get AC. 

Re: 11804 - Argentina
try this test case to make sure your program prints the lexicographically smallest
input
AC output
input
Code: Select all
1
a 99 0
b 99 0
c 99 0
d 99 0
f 33 11
e 33 11
g 32 0
h 32 0
i 32 0
j 32 0
AC output
Code: Select all
Case 1:
(a, b, c, d, e)
(f, g, h, i, j)