#23496: 請問為甚麼會TLE


es811066 (ZIhan)

學校 : 國立臺灣海洋大學
編號 : 108578
來源 : [210.71.40.108]
最後登入時間 :
2023-12-05 16:29:56
f436. 11498 - Division of Nlogonia -- UVA11498 | From: [61.220.150.251] | 發表日期 : 2020-11-23 12:48

#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 (一葉之秋)

學校 : 新北市立板橋高級中學
編號 : 68688
來源 : [1.172.131.82]
最後登入時間 :
2024-01-11 01:11:14
f436. 11498 - Division of Nlogonia -- UVA11498 | From: [1.172.129.165] | 發表日期 : 2020-11-23 13:18

#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 (一葉之秋)

學校 : 新北市立板橋高級中學
編號 : 68688
來源 : [1.172.131.82]
最後登入時間 :
2024-01-11 01:11:14
f436. 11498 - Division of Nlogonia -- UVA11498 | From: [1.172.129.165] | 發表日期 : 2020-11-23 17:13

#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()

 
ZeroJudge Forum