We need 2 arrays — for the first and second team, in which we must save "status" of the player — is he "clear", yellow carded or sent off. Then while inputing we must output the players name if he wasn't sent off, and after the event he must be sent off.
We need to vectors in which we will save points of first and second wrestlers, and two int-s, where we will save who made the last technique and what is the sum of all the numbers in the input. If the sum is not zero, we know the answer. Else we pass by the vectors, checking are there respective elements which are not equal. If yes — then we know the answer, else everything depends on who made the last technique.
We need an array of pairs — in each pair we save the distance and the number of team. Then we sort the array. Then we assume that all the throws bring 3 points. Then we pass by the array and one of our numbers we decrease on 1 (which one — it depends on the second element of array). Then we compare it with our answer. In the end — we print our answer.
If n is odd, then black can win white doing all the moves symetric by the central line. Else white can win putting his queen on (1,2) (which is the lexicographicly smallest place) and play symetricly — never using the first row.
Let's discuss 2 case. 1) t!=1 и 2) t=1.
1) If our function is not constant (n>=1) than a is greater all the coefficients, so the only polynom can be the number b — in the a-ary counting system. We must only check that one and constant function.
2)if t=1 must be careful: in case 1 1 1: the answer is inf, in case 1 1 n: the answer is 0 in case 1 а а^x(x-integer, x>0): the answer is 1 in the other cases P(1) is greater than other coefficients.
else if(c=="y" && hc[no]!=-1) 这里的-1手残写成了0……
这题是足球犯规给牌的记录题目,如果有红牌了之后这个人你就不用管它了(用-1标记就好,以及一个人不能拿两次红牌哦,输出第一次即可),如果给了一张黄牌,记录一下拿过牌了,下一次拿黄牌的时候记得标记改成-1然后输出~
Code:
#include <cmath>
#include <cctype>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int hc[100]={0};
int ac[100]={0};
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
bool cmp(const int a, const int b)
{
return a > b;
}
int main()
{
string h,a; cin>>h>>a;
int n; cin>>n;
for(int i=0;i<n;i++)
{
int time,no;
string w,c;
cin>>time>>w>>no>>c;
if(w=="a")
{
if(c=="r" && ac[no]!=-1)
{
ac[no]=-1;
cout<<a<<" "<<no<<" "<<time<<endl;
}
else if(c=="y" && ac[no]==0)
{
ac[no]=time;
}
else if(c=="y" && ac[no]!=-1)
{
ac[no]=-1;
cout<<a<<" "<<no<<" "<<time<<endl;
}
}
else
{
if(c=="r" && hc[no]!=-1)
{
hc[no]=-1;
cout<<h<<" "<<no<<" "<<time<<endl;
}
else if(c=="y" && hc[no]==0)
{
hc[no]=time;
}
else if(c=="y" && hc[no]!=-1)
{
hc[no]=-1;
cout<<h<<" "<<no<<" "<<time<<endl;
}
}
}
return 0;
}
6 -1 -2 -3 1 2 3
second
first
wrong answer 1st words differ - expected: 'first', found: 'second'
WA 在了上述这个数据上…… 为啥为啥为啥为啥……
然后我在解题报告中看到了这句——then we know the answer, else everything depends on who made the last technique.
好吧……我错了,错在这种地方好不甘心呀……
Code:
#include <cmath>
#include <cctype>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
bool cmp(const int a, const int b)
{
return a > b;
}
int main()
{
int n=0; cin>>n;
ll sum1=0,sum2=0;
int num1[200048]={0},v1=0;
int num2[200048]={0},v2=0;
int last=0;
for(int i=0;i<n;i++)
{
int tmp; scanf("%d",&tmp);
if(tmp>0) sum1+=tmp,num1[v1++]=tmp;
else sum2+=-tmp,num2[v2++]=-tmp;
if(i==n-1)last=tmp;
}
if(sum1>sum2)cout<<"first";
else if(sum2>sum1)cout<<"second";
else
{
if(v1>v2)
{
for(int i=0;i<v2;i++)
{
if(num1[i]==num2[i])continue;
else if(num1[i]>num2[i])
{
cout<<"first";
return 0;
}
else
{
cout<<"second";
return 0;
}
}
cout<<"first";
return 0;
}
else
{
for(int i=0;i<v1;i++)
{
if(num1[i]==num2[i])continue;
else if(num1[i]>num2[i])
{
cout<<"first";
return 0;
}
else
{
cout<<"second";
return 0;
}
}
if(v1==v2 && last<0)cout<<"second";
else if(v1==v2) cout<<"first";
else cout<<"second";
return 0;
}
}
return 0;
}
需要注意的地方挺多的,错了的孩子可以好好琢磨一下这组数据:
4 2 5 3 2 4 1 5 6 2
12:12
12:11
wrong answer 1st words differ - expected: '12:11', found: '12:12'
这是一个十分需要细心的题目……主要是当判断到两队相同米数时很容易出错,需要知道的是,当三分线向外移动时,两个队伍分数是【同时】降低的。
Code:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=200010;
int a[maxn],b[maxn],n,m;
ll x,y,A,B;
int main()
{
cin>>n;
for(int i=0;i<n;i++) cin>>a[i];
cin>>m;
for(int i=0;i<m;i++) cin>>b[i];
sort(a,a+n); sort(b,b+m);
int j=m-1;
A=n; B=m;
for(int i=n-1;i>=0;i--)
{
while(j>=0 && a[i]<=b[j]) j--,y++;
x++;
if(x-y>=A-B) A=x,B=y;
}
if(A<B) A=B=0;
cout<<(ll)n*2+A<<":"<<(ll)m*2+B<<endl;
return 0;
}
博弈,nxn的棋盘,白皇后在(1,1),黑皇后在(1,n),皇后每次只能走相邻的八方向格子(如果相邻的格子被Remove了可以走到这个方向的第一个还健在的格子里),如果走到对方皇后所在格子内或者让对方皇后没路可走则获胜。 很轻易的可以知道,2white,3black,4只要向右一格就变成了3的黑白互换,5同理向右一格变成4所以不这么走即可black胜,依此类推看奇偶性即可。
Code:
#include <cmath>
#include <cctype>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
bool cmp(const int a, const int b)
{
return a > b;
}
int main()
{
int n; cin>>n;
if(n%2)cout<<"black"<<endl;
else cout<<"white"<<endl<<"1 2"<<endl;
return 0;
}