今天心态炸了
第一题贼简单,但g++ 和我有仇 所以只得了25
我的思路:吧id和人名对应,
用一个指针来指位置
利用1和-1来表示朝向内外,左数右数,然后乘了加指针,取模美滋滋
然而
g++给我过了编译,然而
我用了4.8.1和8.1.0的g++,
printf和cin,
它就是不执行输入
下面是代码
#include<bits/stdc++.h>
using namespace std;
long long num,asks,pointer;//逆时针指针
map<long long,string>names;
int torwards[100020];//-1:inside 1:outside
long long steps;
int dir;
char theChar;
int direction;
string name;
void input(){
scanf("%d%d",&num,&asks);
pointer=0;
memset(torwards,-1,sizeof(torwards));
for(int i=0;i<num;i++){
name="";
scanf("%d",&direction);
torwards[i]+=2*direction;
while(theChar!='\n'){
if(theChar>='a'&&theChar<='z')
name+=theChar;
scanf("%c",&theChar);
}
names[i]=name;
}
for(int i=0;i<num;i++){
scanf("%d%lld",&dir,&steps);
//cin>>dir>>steps;
pointer+=(dir*2-1)*steps*torwards[pointer];
pointer=(pointer%num+num)%num;
}
}
void solve(){
cout<<names[pointer];
}
int main(){
#ifdef DEBUG
freopen("1.txt","r",stdin);
#endif
input();
solve();
}