班上两个蒻至daolao想挑战不可能(赌阳寿),于是写了一份随机数代码,但TLE了,求调。
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
bool ans;
int r,c,s;
inline void run(){
int n,q;
ans=0;
cin>>n>>s>>q;
while(q--){
cin>>r>>c;
cout<<rand()%2<<endl;
}
}
int main(){
srand(time(0));
int T;
cin>>T;
while(T--) run();
return 0;
}
提交记录
but
如果把run函数的while里面的输入注释掉,就不会TLE
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
bool ans;
int r,c,s;
inline void run(){
int n,q;
ans=0;
cin>>n>>s>>q;
while(q--){
cout<<rand()%2<<endl;
}
}
int main(){
srand(time(0));
int T;
cin>>T;
while(T--) run();
return 0;
}
提交记录
希望有好心人帮忙看一看!!!