#23496: 請問為甚麼會TLE


es811066 (ZIhan)


#include<bits/stdc++.h>

using namespace std;

int main(){

int a;

ios::sync_with_stdio(false);

cin.tie(0);

while(cin>>a){

if(!a)break;

int b,c;

cin>>b>>c;

while(a--){

int d,e;

cin>>d>>e;

if(d==b||e==c){

cout<<"divisa"<<endl;

}

else if(d<b&&e>c){

cout<<"NO"<<endl;

}

else if(d<b&&e<c){

cout<<"SO"<<endl;

}

else if(d>b&&e>c){

cout<<"NE"<<endl;

}

else cout<<"SE"<<endl;

}

}

}

#23497: Re:請問為甚麼會TLE


DE45A (一葉之秋)


#include<bits/stdc++.h>

using namespace std;

int main(){

int a;

ios::sync_with_stdio(false);

cin.tie(0);

while(cin>>a){

if(!a)break;

int b,c;

cin>>b>>c;

while(a--){

int d,e;

cin>>d>>e;

if(d==b||e==c){

cout<<"divisa"<<endl;

}

else if(d<b&&e>c){

cout<<"NO"<<endl;

}

else if(d<b&&e<c){

cout<<"SO"<<endl;

}

else if(d>b&&e>c){

cout<<"NE"<<endl;

}

else cout<<"SE"<<endl;

}

}

}


你加上cout.tie(0)看看

#23498: Re:請問為甚麼會TLE


DE45A (一葉之秋)


#include<bits/stdc++.h>

using namespace std;

int main(){

int a;

ios::sync_with_stdio(false);

cin.tie(0);

while(cin>>a){

if(!a)break;

int b,c;

cin>>b>>c;

while(a--){

int d,e;

cin>>d>>e;

if(d==b||e==c){

cout<<"divisa"<<endl;

}

else if(d<b&&e>c){

cout<<"NO"<<endl;

}

else if(d<b&&e<c){

cout<<"SO"<<endl;

}

else if(d>b&&e>c){

cout<<"NE"<<endl;

}

else cout<<"SE"<<endl;

}

}

}


你加上cout.tie(0)看看

然後endl換成"\n" 或改用scanf(),printf()