제출 #846365

#제출 시각아이디문제언어결과실행 시간메모리
846365vjudge1KOVANICE (COI15_kovanice)C++17
50 / 100
590 ms41952 KiB
#include<bits/stdc++.h> #define int long long #define MOD 1000000007 #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; vector<pair<int,int>>v[300005]; vector<int>v3; int mn,mx,vis[300005],ans[300005]; void dfs(int node,int x){ vis[node]=1; ans[node]=x; mn=min(mn,x); mx=max(mx,x); v3.pb(node); for(auto i:v[node]){ if(vis[i.ff])continue; dfs(i.ff,x+i.ss); } return; } int32_t main(){ int n,m,k; cin>>n>>m>>k; for(int i=1;i<=m;i++)ans[i]=-1; vector<pair<int,int>>v2; for(int i=0;i<k;i++){ string s; cin>>s; int a=0,b=0; string s2,s3; int ind=0; while(s[ind]!='<' && s[ind]!='='){ s2+=s[ind]; ind++; } int temp=ind; ind++; while(ind<s.size()){ s3+=s[ind]; ind++; } a=stoi(s2); b=stoi(s3); if(s[temp]=='='){ v[a].pb({b,0}); v[b].pb({a,0}); } else{ v[a].pb({b,1}); v[b].pb({a,-1}); v2.pb({a,0}); v2.pb({b,1}); } } for(auto i:v2){ if(vis[i.ff])continue; v3.clear(); mn=1e15,mx=-1e15; dfs(i.ff,0); if(mx-mn+1==n){ for(auto i:v3){ ans[i]-=mn; } } } for(int i=1;i<=m;i++){ if(ans[i]==-1)cout<<"?"<<endl; else cout<<"K"<<ans[i]+1<<endl; } }

컴파일 시 표준 에러 (stderr) 메시지

kovanice.cpp: In function 'int32_t main()':
kovanice.cpp:46:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   while(ind<s.size()){
      |         ~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...